<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>宅鱼</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="google-site-verification" content="yH7MwnMb7LXru16F4FAfY94pn-oZLhF8Szu4PuL7Oxw" />
  <meta name="description" content="前端，技术，博客，记录，javascript，html5，css">
<meta property="og:type" content="website">
<meta property="og:title" content="宅鱼">
<meta property="og:url" content="http://ikkkr.com/page/9/index.html">
<meta property="og:site_name" content="宅鱼">
<meta property="og:description" content="前端，技术，博客，记录，javascript，html5，css">
<meta property="og:locale" content="default">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="宅鱼">
<meta name="twitter:description" content="前端，技术，博客，记录，javascript，html5，css">
  
    <link rel="alternative" href="/atom.xml" title="宅鱼" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.ico"  type="image/x-ico">
   
  <link rel="stylesheet" href="/css/style.css">
  

</head>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">宅鱼</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">部落格</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">首页</a>
        
          <a class="main-nav-link" href="/archives">文章</a>
        
          <a class="main-nav-link" href="/raincss">RainCSS</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://ikkkr.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-java-e4-b8-ad-e7-9a-84memoization-e5-ae-9e-e7-8e-b0-implement-memoization-in-java" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/12/14/java-e4-b8-ad-e7-9a-84memoization-e5-ae-9e-e7-8e-b0-implement-memoization-in-java/" class="article-date">
  <time datetime="2011-12-14T14:42:28.000Z" itemprop="datePublished">2011-12-14</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/computer-science/">computer science</a>►<a class="article-category-link" href="/categories/computer-science/java-web/">java web</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/12/14/java-e4-b8-ad-e7-9a-84memoization-e5-ae-9e-e7-8e-b0-implement-memoization-in-java/">java中的Memoization实现_Implement Memoization in java</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>Memoization 在具有函数式编程特性的语言中用于缓存函数运算后的结果值,在java中可以使用动态代理实现这一特性，但对于java中的递归的运算,其不能缓存递归的过程值,而python,lisp等函数式特性的动态语言则能对每一次运算进行缓存.</p>
<p>Memoization的简单介绍如下:<br>我们在第一次计算一个值后就记录一个值.然后在后续问题中使用这个值.<br>we record a value the first time it’s computed,then look it up the subsequent times we need it.</p>
<p>这就是动态编程这种通用技术的核心<br>And this is what lies at the heart of this very general technique called dynamic programming.</p>
<p>实际上 它也是很多保存结果的计算技巧的核心<br>And in fact,it lies at the heart of a lot of useful computational techniques where we save results.</p>
<p><strong>java具体的类可以这样实现:</strong></p>
<p>import java.lang.reflect.InvocationHandler;<br>import java.lang.reflect.InvocationTargetException;<br>import java.lang.reflect.Method;<br>import java.lang.reflect.Proxy;<br>import java.util.Arrays;<br>import java.util.Collections;<br>import java.util.HashMap;<br>import java.util.List;<br>import java.util.Map;</p>
<p>public class Memoizer implements InvocationHandler {<br>public static Object memoize(Object object) {<br>return Proxy.newProxyInstance(object.getClass().getClassLoader(), object.getClass().getInterfaces(), new Memoizer(<br>object));<br>}</p>
<p>private Object object;<br>private Map caches = new HashMap();</p>
<p>private Memoizer(Object object) {<br>this.object = object;<br>}</p>
<p>public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {</p>
<p>if (method.getReturnType().equals(Void.TYPE)) {<br>// Don’t cache void methods<br>return invoke(method, args);<br>} else {<br>Map cache = getCache(method);<br>List key = Arrays.asList(args);<br>Object value = cache.get(key);</p>
<p>System.out.println(“get cache value ===”+value);<br>if (value == null &amp;&amp; !cache.containsKey(key)) {<br>value = invoke(method, args);<br>System.out.println(“put cache value ===”+key +”–”+value);<br>cache.put(key, value);<br>}<br>return value;<br>}<br>}</p>
<p>private Object invoke(Method method, Object[] args) throws Throwable {<br>try {<br>return method.invoke(object, args);<br>} catch (InvocationTargetException e) {<br>throw e.getTargetException();<br>}<br>}</p>
<p>private synchronized Map getCache(Method m) {<br>Map cache = (Map) caches.get(m);<br>if (cache == null) {<br>cache = Collections.synchronizedMap(new HashMap());<br>caches.put(m, cache);<br>}<br>return cache;<br>}<br>}</p>
<p>然后可以构造一个接口:</p>
<p>public interface Car {<br>public int fibonacci(int n);<br>}</p>
<p>一个实现类:</p>
<p>public class CarImpl implements Car {<br>public int fibonacci(int n) {<br>if (n == 0 || n == 1)<br>return 1;<br>return fibonacci(n - 1) + fibonacci(n - 2);<br>}<br>}</p>
<p>在调用时候:</p>
<p>Car foo = (Car) Memoizer.memoize(new CarImpl());<br>int n = foo.fibonacci(5);//直接运算并对结果进行缓存<br>int rr = foo.fibonacci(6);//直接运算并对结果进行缓存，不能够获取fibonacci(5)的结果值</p>
<p>但是若:</p>
<p>int n = foo.fibonacci(5);//直接运算并对结果进行缓存<br>int rr = foo.fibonacci(5);//直接获取缓存值</p>
<p><strong>但在函数式特性的语言中(javascript):</strong></p>
<p>function memoize(fundamental, cache){<br>cache = cache || {};<br>var shell = function(arg){<br>if (!cache.hasOwnProperty(arg)){<br>cache[arg] = fundamental(arg);<br>}<br>return cache[arg];<br>};<br>return shell;<br>}</p>
<p>function factorial(n){<br>if (n==0 || n==1){ return 1;}<br>return factorial(n-1)+factorial(n-2);<br>}</p>
<p>//memoize the factorial function<br>var memfactorial = memoize(factorial, { 0: 1, 1: 1 });</p>
<p>//call the new function<br>var fact6 = memfactorial(6);</p>
<p>var fact5 = memfactorial(5);//直接获取前面已经计算过的结果<br>console.info(fact6);<br>console.info(fact5);</p>
<p><strong>wiki中对Memoization的介绍:</strong></p>
<p>In <a href="http://en.wikipedia.org/wiki/Computing" title="Computing" target="_blank" rel="noopener">computing</a>, <strong>memoization</strong> is an <a href="http://en.wikipedia.org/wiki/Optimization_%28computer_science%29" title="Optimization (computer science)" target="_blank" rel="noopener">optimization</a> technique used primarily to speed up <a href="http://en.wikipedia.org/wiki/Computer_programs" title="Computer programs" target="_blank" rel="noopener">computer programs</a> by having <a href="http://en.wikipedia.org/wiki/Subroutine" title="Subroutine" target="_blank" rel="noopener">function calls</a> avoid repeating the calculation of results for previously processed    inputs. Memoization has also been used in other contexts (and for    purposes other than speed gains), such as in simple <a href="http://en.wikipedia.org/wiki/Mutual_recursion" title="Mutual recursion" target="_blank" rel="noopener">mutually recursive</a> descent parsing<sup id="cite_ref-Norvig1991_0-0"><a href="http://en.wikipedia.org/wiki/Memoization#cite_note-Norvig1991-0" target="_blank" rel="noopener">[1]</a></sup> in a general <a href="http://en.wikipedia.org/wiki/Top-down_parsing" title="Top-down parsing" target="_blank" rel="noopener">top-down</a> <a href="http://en.wikipedia.org/wiki/Parsing" title="Parsing" target="_blank" rel="noopener">parsing</a> algorithm<sup id="cite_ref-FrostHafizCallaghan2007_1-0"><a href="http://en.wikipedia.org/wiki/Memoization#cite_note-FrostHafizCallaghan2007-1" target="_blank" rel="noopener">[2]</a></sup><sup id="cite_ref-FrostHafizCallaghan2008_2-0"><a href="http://en.wikipedia.org/wiki/Memoization#cite_note-FrostHafizCallaghan2008-2" target="_blank" rel="noopener">[3]</a></sup> that accommodates ambiguity and <a href="http://en.wikipedia.org/wiki/Left_recursion" title="Left recursion" target="_blank" rel="noopener">left recursion</a> in polynomial time and space. Although related to <a href="http://en.wikipedia.org/wiki/Cache" title="Cache" target="_blank" rel="noopener">caching</a>, memoization refers to a specific case of this optimization, distinguishing it from forms of caching such as <a href="http://en.wikipedia.org/wiki/Buffer_%28computer_science%29" title="Buffer (computer science)" target="_blank" rel="noopener">buffering</a> or <a href="http://en.wikipedia.org/wiki/Page_replacement_algorithm" title="Page replacement algorithm" target="_blank" rel="noopener">page replacement</a>. In the context of some <a href="http://en.wikipedia.org/wiki/Logic_programming" title="Logic programming" target="_blank" rel="noopener">logic programming</a> languages, memoization is also known as <a href="http://en.wikipedia.org/wiki/Prolog#Tabling" title="Prolog" target="_blank" rel="noopener">tabling</a>;<sup id="cite_ref-Warren1999_3-0"><a href="http://en.wikipedia.org/wiki/Memoization#cite_note-Warren1999-3" target="_blank" rel="noopener">[4]</a></sup> see also <a href="http://en.wikipedia.org/wiki/Lookup_table" title="Lookup table" target="_blank" rel="noopener">lookup table</a>.</p>
<p>关于java Memoization实现的文章:</p>
<p><a href="http://onjava.com/pub/a/onjava/2003/08/20/memoization.html" target="_blank" rel="noopener">Memoization in Java Using Dynamic Proxy Classes</a></p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/算法/">算法</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/编程/">编程</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/语言/">语言</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-e5-af-bc-e6-95-b0-e4-b8-8e-e7-89-9b-e9-a1-bf-e8-bf-ad-e4-bb-a3-e6-b3-95-derivative-and-newton-iterative-algorithm" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/11/06/e5-af-bc-e6-95-b0-e4-b8-8e-e7-89-9b-e9-a1-bf-e8-bf-ad-e4-bb-a3-e6-b3-95-derivative-and-newton-iterative-algorithm/" class="article-date">
  <time datetime="2011-11-06T14:40:53.000Z" itemprop="datePublished">2011-11-06</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/computer-science/">computer science</a>►<a class="article-category-link" href="/categories/computer-science/算法/">算法</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/11/06/e5-af-bc-e6-95-b0-e4-b8-8e-e7-89-9b-e9-a1-bf-e8-bf-ad-e4-bb-a3-e6-b3-95-derivative-and-newton-iterative-algorithm/">导数与牛顿迭代法_Derivative and Newton iterative algorithm</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p><strong>导数的概念</strong>:<br>设y=f(x)在x0的邻域U内有定义,x0,x0+△x∈U,△x:该变量,增量.△y = f(x0+△x)-f(x0),△y/△x = [f(x0+△x)-f(x0)]/△x;<br>如果lim<sub>(△x-&gt;0)</sub> △y/△x 存在,则称此极限为f(x)在x0处的导数.记为:f’(x0)或y’|<sub>(x=x0)</sub>或dy/dx|<sub>(x=x0)</sub></p>
<p>1.给定f(x),x0,则f’(x0)随之而确定,f’(x0)是一个数.<br>2.求导过程中△x-&gt;0是变量<br>3.若f(x)在(a,b)内每一点都可导,则称f(x)在(a,b)区间可导.<br>f’(x0) = lim<sub>(△x-&gt;0)</sub> △y/△x;</p>
<p>例如:f(x) = x<sup>3</sup> ,求x=2时的导数.</p>
<p>f ‘ (x) = △y/△x;</p>
<p>△y = f(x+△x) - f(x) = (x+△x)<sup>3</sup>-x<sup>3</sup> = 3<em>x<sup>2</sup></em>△x + 3<em>x</em>△x<sup>2</sup> + △x<sup>3</sup> ;</p>
<p>所以f ‘ (x) = 3*x<sup>2</sup> ;(因为△x趋向于0);</p>
<p>f ‘ (2) =12;</p>
<p>导数的一些性质:</p>
<p>几何性质:曲线y = f(x)在(x0,f(x0))的切线存在,且此切线不垂直于x轴.<br>(曲线折点切线不存在,点切线垂直于x轴,tg 值无限大,所以不可导)</p>
<p>wiki导数的介绍: <a href="http://zh.wikipedia.org/wiki/%E5%AF%BC%E6%95%B0" target="_blank" rel="noopener">导数</a></p>
<p><strong>牛顿迭代法的公式为 :</strong></p>
<p>如果f ‘ (x<sub>n-1</sub>)!=0;那么 x<sub>n</sub> = x<sub>n-1</sub> - f(x<sub>n-1</sub>)/f ‘ (x<sub>n-1</sub>);</p>
<p><strong>推导过程为:</strong></p>
<p>假设有函数f(x),使得f(x) = 0;</p>
<p>求此时x的值,在函数上取一点x0,其下一个点值f(x1)比f(x0)更接近与0,这个时候假设x0的值f(x0)趋近f(x)的值,<br>则可以假设此点的切线斜率为k:</p>
<p>则F(x1)-F(x0) = k(x1-x0).而斜率为f(x0) 的导数f ‘ (x0),而F(x1)=0;</p>
<p>所以:x1= x0 - f(x0)/f ‘ (x0);</p>
<p>示例:求任意一个正数的平方根.</p>
<p>牛顿迭代法则可以视为:求函数f(x) = x<sup>2</sup> - N = 0 的解.</p>
<p>java代码如下:</p>
<p>public static double sqrt(double n, double guess) {</p>
<p>if (n &gt; 0 &amp;&amp; guess &gt; 0) {</p>
<p>double temp = (guess + n / guess) / 2;</p>
<p>if (temp == guess) {</p>
<p>return temp;</p>
<p>} else {</p>
<p>System.out.println(“the newton computation –” + temp);</p>
<p>return sqrt(n, temp);</p>
<p>}</p>
<p>}</p>
<p>return 0;</p>
<p>}</p>
<p>同样也可以使用二分法来实现求解,代码如下:</p>
<p>public static double bisectionSqrt(double n, double min, double max) {</p>
<p>if (n &gt; 0) {</p>
<p>double mid = (min + max) / 2;</p>
<p>double temp = mid * mid;</p>
<p>if (Math.abs(n - temp) &lt;= 0.000000001) {</p>
<p>return mid;</p>
<p>} else if (temp &gt; n) {</p>
<p>max = mid - 1;</p>
<p>System.out.println(“the bisection computation –” + mid);</p>
<p>return bisectionSqrt(n, min, max);</p>
<p>} else if (temp &lt; n) {</p>
<p>min = mid + 1;</p>
<p>System.out.println(“the bisection computation –” + mid);</p>
<p>return bisectionSqrt(n, min, max);</p>
<p>}</p>
<p>}</p>
<p>return 0;</p>
<p>}</p>
<p>牛顿法在解决问题的效率上远远大于二分法:</p>
<p>public static void main(String args[]) {</p>
<p>System.out.println(sqrt(3, 2));</p>
<p>System.out.println(bisectionSqrt(3, 0, 3));</p>
<p>}</p>
<p>计算结果为:</p>
<p>the newton computation –1.75</p>
<p>the newton computation –1.7321428571428572</p>
<p>the newton computation –1.7320508100147274</p>
<p>the newton computation –1.7320508075688772</p>
<p>1.7320508075688772</p>
<p>the bisection computation –1.5</p>
<p>the bisection computation –2.75</p>
<p>the bisection computation –2.125</p>
<p>the bisection computation –1.8125</p>
<p>the bisection computation –1.65625</p>
<p>the bisection computation –1.734375</p>
<p>the bisection computation –1.6953125</p>
<p>the bisection computation –1.71484375</p>
<p>the bisection computation –1.724609375</p>
<p>the bisection computation –1.7294921875</p>
<p>the bisection computation –1.73193359375</p>
<p>the bisection computation –1.733154296875</p>
<p>the bisection computation –1.7325439453125</p>
<p>the bisection computation –1.73223876953125</p>
<p>the bisection computation –1.732086181640625</p>
<p>the bisection computation –1.7320098876953125</p>
<p>the bisection computation –1.7320480346679688</p>
<p>the bisection computation –1.7320671081542969</p>
<p>the bisection computation –1.7320575714111328</p>
<p>the bisection computation –1.7320528030395508</p>
<p>the bisection computation –1.7320504188537598</p>
<p>the bisection computation –1.7320516109466553</p>
<p>the bisection computation –1.7320510149002075</p>
<p>the bisection computation –1.7320507168769836</p>
<p>the bisection computation –1.7320508658885956</p>
<p>the bisection computation –1.7320507913827896</p>
<p>the bisection computation –1.7320508286356926</p>
<p>the bisection computation –1.732050810009241</p>
<p>the bisection computation –1.7320508006960154</p>
<p>the bisection computation –1.7320508053526282</p>
<p>1.7320508076809347</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/算法/">算法</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/编程/">编程</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-mit-e8-ae-a1-e7-ae-97-e6-9c-ba-e7-a7-91-e5-ad-a6-e5-8f-8a-e7-bc-96-e7-a8-8b-e5-af-bc-e8-ae-ba-e7-ac-94-e8-ae-b0-introduction-to-computer-science-and-programing-note" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/10/23/mit-e8-ae-a1-e7-ae-97-e6-9c-ba-e7-a7-91-e5-ad-a6-e5-8f-8a-e7-bc-96-e7-a8-8b-e5-af-bc-e8-ae-ba-e7-ac-94-e8-ae-b0-introduction-to-computer-science-and-programing-note/" class="article-date">
  <time datetime="2011-10-23T14:37:39.000Z" itemprop="datePublished">2011-10-23</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/computer-science/">computer science</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/10/23/mit-e8-ae-a1-e7-ae-97-e6-9c-ba-e7-a7-91-e5-ad-a6-e5-8f-8a-e7-bc-96-e7-a8-8b-e5-af-bc-e8-ae-ba-e7-ac-94-e8-ae-b0-introduction-to-computer-science-and-programing-note/">MIT计算机科学及编程导论笔记_Introduction to Computer Science and Programing Note</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p><strong>1.Goal of the course;what is computation;introduction to data types,operators,and variables</strong><br>what is knowledge?<br>I can divide knowledge into at least two categories.<br>陈述性知识和程序性知识<br>are declarative and imperative knowledge.<br>任何可以合法使用值的地方都可以使用变量<br>So,any place it’s legal to use the value.</p>
<p><strong><br>2.Operators and operands statements;branching,conditionals,and iteration</strong><br>分支程序就是一个能基于一些测试来改变指令顺序的程序<br>a branching program is something that can change the order of instructions based on some test</p>
<p><strong><br>3.Common code patterns:iterative programs</strong><br>在写每个循环程序的时候确保他们总是能终结,第二件要做的事情就是要确保程序返回了正确的答案<br>you’d like to be able to assrue yourself that they will always  terminate,and then the second thing you’d like to do,is to assure  yourself that it does give you back a reasonable answer.<br><strong>4.Decomposition and abstraction through functions;introcuction to recursion</strong><br>函数的关键是它要提供分解和抽象<br>the key of the function is that it’s going to provide both of these.<br>将代码分解为模块<br>it’s going to let us break up into modules.<br>忽略细节<br>suppress detail.<br>一种创建原语的思考方式,我们将引用这些原语,这就是继承<br>it is to create new primitives.and i’m going to put those in quotes,it’s a generalization.<br>函数的目的就是寻找计算的共同模式<br>The idea of a function is,that i’m going to capture a common pattern of computation.</p>
<p>这些本地绑定并不影响全局绑定<br>These local bingdings do not affect any global bindings.</p>
<p>递归的概念就是我将把一个问题进行分解成一个更简单的同类问题以解决我可以解决的小步骤<br>The idea of recursion is that I’m going to take a problem and break it  down into a simpler version of the same problem plus some steps</p>
<p>Fibonacci<br>Pairs(0) = 1;<br>Pairs(1) = 1;<br>Pairs(n) = Pairs(n-1) + Pairs(n-2);</p>
<p><strong>5.Floating point numbers,successive refinement,finding roots</strong><br>当我们表达一些数字的时候尾数位于1和2之间,严格的小于2<br>when we represent something,the mantissa is between one and two.Strictly less than two.<br>而指数在-1022到+1023之间<br>The exponent,is in the range,-1022 to +1023<br>因此我们表达的数字可以从正负10到正负308th<br>So this lets us represent numbers up to about 10 to the 308th,plus or minus to the 308th,plus or minus.<br>现代计算机语言是64位的<br>the words today in a modern computer are 64 bits<br>我们设立1位以存储符号这个数字是整数还是负数然后11字节存储指数剩下的52个字节存放尾数(小数)<br>we get one bit for the sign is it a positive or negative number 11 for the exponent,and that leaves 52 for the mantissa</p>
<p>有些10进制的数如1/10 ,在转变为二进制的时候会无限循环下去</p>
<p>打印十进制数字的近似二进制数<br>So on most computers,if you were to print the decimal value of the binary approximation</p>
<p>repr()函数将数字以字符串表达.<br>对于浮点数 计算机截至第17位数<br>for floats,it rounds it to seventeen digits</p>
<p>warry about == on floats<br>每一次猜想都比前一次的更接近答案的方法,这就是逐次逼近法<br>that each guess is better than the previous guess<br>This is what’s called successive approximation<br>起始猜想,然后迭代<br>which would be the initial guess,you then iterate</p>
<p>Bisection method二分法<br>处理过程是对数级的<br>because I am getting logarithmically progressed</p>
<p><strong>6.Bisection methods,Newton/Raphson,introduction to lists</strong></p>
<p>我们实际上是在解方程式f:猜想数的平方减去x<br>we are looking a equation f of guess equals the guess squared minus x.</p>
<p>我们正需求方程式f=0的解.<br>and we trying to solving the equation that f of guess equals 0.Looking for the root of this equation.</p>
<p>sqrt(x);<br>F(guess) = guess^2 -x;</p>
<p>猜想切线(导数)<br>You take a guess and you find the tangent of that guess.</p>
<p>下一个猜想是切线与x的交点.<br>My next guess is going to be where the tangent crosses the x axis.</p>
<p>这里用到了导数的概念,<br>This is where derivatives come in.</p>
<p>我们都知道切点处切线的斜率跟函数在切点处的一阶导数是相同的,也就是dy/dx<br>What we know is that the slope of the tangent is given by the first  derivative of the function f at the point of the guess.Which dy over dx.</p>
<p>guess(i+1) = guess(i) -F(guess(i))/2*guess(i);</p>
<p>可以将第i+1次猜想等于上一次猜想也就是第i次的减去第i次的猜测的结果值除以第i次猜想的本身值<br>we’ll know that we can choose guess i plus 1 to be equal to the old  guess guess i,minus whatever the value is of the new guess–of the old  rather the old guess– divided by twice the old guess.</p>
<p>从猜想数3开始求16平方根<br>F(3) = 9 -16 = -7;<br>guess(i+1) = 3 -(-7/6) = 4.1666</p>
<p><strong>7.Lists and mutability,dictionaries,pseudocode,introduction to efficiency</strong></p>
<p>order of grows<br>-choice of algorithm<br>-map problem into class of algorithms</p>
<p><strong>8.Complexity; log,linear,quadratic,exponential algorithms</strong></p>
<p>增长率,当问题的规模变大时,随之时间和空间的增长<br>Rate of growth as the size of the problem grows.<br>If it was,how much bigger does this get<br>大O符号,代表着当输入增加时也就是问题规模变大时对应的解决方法增长上限<br>Big Oh notation - is basically going to be an upper limit to the growth  of a function as the input grow–as the input gets large.</p>
<p>a的b次方<br>a<strong>b  = (a*a)</strong>(b/2) b even;<br>= a<em>(a**(b-1)) b odd;<br>ef exp3(a,b):<br>if b==1:<br>return a;<br>if(b%2)</em>2 == b:<br>return exp3(a<em>a , b/2);<br>else: return a</em>exp3(a,b-1);<br>b even t(b) = 6 + (b/2);<br>b odd t(b) =  6 + (b-1) = 12 + t((b-1)/2)</p>
<p>t(b) = 12 + (b/2);<br>=12+12+t(b/4)<br>=12k+t(b/2^k)</p>
<p>k=log2 b;<br>In the b even case, again i’m going to let t of b be the number of steps I want to go through.<br>if b is eqaul to 1,and then I’ve got to do the remainder(求余数),the multiplication,and the test,i’m up to four.</p>
<p>And then in the even case I’ve got to do a square(求平方) and the divide.<br>So i’ve got six steps<br>对数级,线性的,平方级,指数级算法<br>log,Linear ,quadratic,exponential algorithm</p>
<p><strong>9.Binary search,bubble and selection sorts </strong></p>
<p>但如果我们用的是保存列表的列表呢?如果列表存储的不同的东西 比如存储的是整数 字符串 浮点数 列表 列表的列表 列表的列表的列表 或者其他各种东西呢?<br>if i know that i have things stored in constant size.But what if i have a  list of lists?What if i have a homogeneous list,a list of integers and  strings and floats and  lists and lists of lists and lists of lists of  lists<br>标准的处理方法是使用链表<br>So in this case,one of the standard ways to use linked list<br>开始我们指向列表的开始<br>Start again,we’ll point to the beginning of the list.<br>在第一点,我们存下一个元素的地址偏移量,然后 用之后连续的几个单元表示第一个元素 如果你喜欢也可以说是第0个元素.在这里  我可能需要五个内存单元在下一个位置中 存放需要多大的内存偏移量跳转到下一个元素然后无论你想存放什么都可以放在接下来的单元中 可能只是些空格<br>在下一点可能我得存放一个很长的列表了</p>
<p>in the first spot,I am going to store something that says,here’s how far  you have to jump to get to the next element.And then,I am going to use  the next sequence of things to represent the first element,or the  zero-th element,if you like.In this case I might need five.And then in  the next spot,I am going to say how far you have to jump to get to the  next element.All right,followed by whatever i need to represent it,which  might only be a blank one.And in the next spot,maybe I’ve got a really  long list</p>
<p>here is the problem.How do i get to the nth er,the k’th element in the list,in this case?<br>Well i have to go to the zero-th element,and say OK,gee,to get to the  next element,I’ve got to jump this here.And to get to the next  element,I’ve got to jump to here,and to get to the next element,I’ve got  to jump to here,until i get there.<br>primarily Lisp.<br>盒状指南针每个元素实际上由两部分组成这里我们颠倒了顺序 这里有指针指向内存包含实际值的地址 可能实际值也是一系列指针 这里还有指向实际指向下一个元素的指针<br>Python store list, it is called a box pointer diagram,what we really  have for each element is two things.And i’ve actually just reversed the  order here.we have a pointer to the location in memory that contains the  actual value,which itself might be a bunch of pointers,and we have a  pointer to the actual a pointer the value and we have a pointer</p>
<p>一次一个的比较遍历这些元素直到找到了它,这个复杂度是n<br>I am just going to take an unsorted list and search it,i cound do it in  linear time,right?One at a time.Walk down the elements until i find  it.That wound be order n.<br>另一种方法,先排序再搜索,需要花nlog n时间排序,然后花log n时间搜索<br>On the other hand,sort it first,and search.take n logn time to sort it,then i can search it in log n time.</p>
<p>amortize the cost.<br>Linear   sort + search<br>kn      nlog n + klog n</p>
<p>bubbule sort<br>我遍历一次列表 每次取两个值 确认最大的元素在后面一个<br>I’m walking along the list once,taking two things,and saying, make sure the biggest one is next.</p>
<p>所以无论最大的元素在列表的什么位置 跑完了一遍 它总是在最下面 然后我回来再做一次,下一个最大元素又能跑到倒数第二的位置.<br>So wherever the largest element started out in the list,by the time i  get through it,it’s at the end.And then i go back and i start again,and i  do the same thing.The next largest element has to end up in the second  last spot.</p>
<p>divide and conquer algorithm<br>分而治之</p>
<p><strong>10. Divide and conquer methods,merge sort,exceptions</strong></p>
<p>merge sort</p>
<p>所以我在树的每个层次都要做O(n)的操作,因为在每一层 我都是把问题分解成两半,以n开始 然后是n/2 n/4 n/8 所以我log n遍的n次操作<br>have order n operations at each level in the  tree.And then we have Log n  level,Beacause at each stage i cute problem in half.So i start off with  n then it’s n over two n over four n over eight.So i have n operations  log n times, n log n</p>
<p>hashing<br>Trade space for time 用空间换时间</p>
<p><strong>11. Testing and Debugging</strong></p>
<p>validation<br>progress to uncover problem and increase confidence.<br>我们需要一种不会我们这种无保证的自信的方法<br>So we need to have a method not designed to give us unwarranted confidence.</p>
<p>是两件事情的组合 测试和推理<br>It’s typically a combination of two things.Testing and reasoning.<br>测试就是 我们输入一些信息并且运行我们的程序 然后查看答案<br>Testing we run our program on some set of inputs.And check the answers,and say yeah</p>
<p>debugging<br>这其实是一个查明为什么程序不运行或者不按期待运行的过程<br>And that’s basically the process of ascertaining why the program is not working.</p>
<p>Defensive programming.防卫性程序设计</p>
<p>And that’s basically writing your programs in such a way that it will  facilitate both validation and dubugging.</p>
<p>实验必须有做什么的能力才能被称为一个有效的科学实验呢?<br>what must this experiment have the potential to do,to be a valid scientific experiment?<br>实验必须有反驳我们假设的可能<br>It must have the potential to refute the hypothesis.</p>
<p><strong>12. More about debugging,knapsack problem,introduction to dynamic programming</strong></p>
<p>first,keep in mind that the bug is probably not where you think it is.</p>
<p>simple things you can care:</p>
<p>自变量顺序错误<br>Reversed order of arguments.</p>
<p>忘记初始化<br>Initialization.</p>
<p>对象与值相等<br>Object versus value equality.</p>
<p>别名<br>Aliasing deep vs shallow capy.</p>
<p>Keep record of what you tried.</p>
<p>Think about reconsidering your assumptions.</p>
<p>Bin packing</p>
<p>sequence alignment</p>
<p>Knapsack problem 背包问题</p>
<p>Continuous problem 连续问题<br>4/bs Au dust<br>3/bs Ag dust<br>10/bs Raisins</p>
<p>function is cost value of gold times how many pounds of gold.Plus the  cost of silver times however many pounds of silver.Plus cost of raisins  times the number of pounds of raisins.<br>maximize the function Cg <em> PG + Cs </em> PS + Cr * PR</p>
<p>the constraint is PG + PS + PR &lt;=8<br>Greedy algorithm<br>at every step you do what maximizes your value at that step.So there’s no planning ahead.You just do what is ever best.</p>
<p>Locally optinal  not always lead to global optimums.</p>
<p>zero-one knapsack problem 0/1 背包问题<br>exhaustive enumeration 穷举法</p>
<p>E(n ,i = 1) W i X i &lt;= C</p>
<p>Dynamic programming</p>
<p>有重叠子问题且被称为最理想子结构的情况<br>there are overlapping sub-problems and what’s called optimal substructrue.</p>
<p>redundant computation 累赘计算</p>
<p><strong>13.Dynamic programming: overlapping subproblems,optimal substructure</strong></p>
<p>Overlapping subproblems 重叠子问题<br>Memoization<br>我们在第一次计算一个值后就记录一个值.然后在后续问题中使用这个值.<br>we record a value the first time it’s computed,then look it up the subsequent times we need it.</p>
<p>这就是动态编程这种通用技术的核心<br>And this is what lies at the heart of this very general technique called dynamic programming.</p>
<p>实际上 它也是很多保存结果的计算技巧的核心<br>And in fact,it lies at the heart of a lot of useful computational techniques where we save results.</p>
<p>Decision Tree 决策树<br>Back track</p>
<p><strong>14.Analysis of knapsack problem,introduction to object-oriented programming</strong></p>
<p>Size of solution<br>运行时间与装进背包的物品数目有关<br>how long it takes to run is related to how many items i end up being able to  fit into the knapsack.<br>要记住的物品数量是和我能在背包中装多少东西有关<br>So the number of items i have to remember is related to how many items i can fit in the Knapsack.</p>
<p>这里有的是伪多项式算法<br>so we’d much rather define big O in terms of the inputs.</p>
<p>通常我们查看计算复杂度O的时候 我们会把它定义为实现输入的代码的大小<br>computational complexity,big O,what we’ll define the in terms of,is the size of the coding of the input.<br>size of coding of input</p>
<p>Pseudo polynomial algorithm 伪多项式</p>
<p>polynomial in the  numeric value of input</p>
<p>1.动态编程中,我们是在用空间换时间<br>In dynamic programming, one of the things that’s going on is we’re trading time for space.</p>
<p>2. 不要被指数型问题吓到<br>Two,don’t be intimidated by exponential problems.</p>
<p>3. 动态编程有广泛的应用,每当你在处理一个看上去有自然而然的递归算法的时候</p>
<p>Dynamic programming is broadly useful.Whenever you’re looking at a  problem that seems to have a natural recursive solution,think about  whether you can attact it with dynamic programming.</p>
<p>4. 减少问题 problem reduction</p>
<p>Module (modularity)<br>我想要说的是一种类型的模块当然这是因为我们关注的是程序的可组合性<br>what i want to be talking about is modules of one sort,and of course that’s because what we’re interested in is modularity.</p>
<p>模块是相识函数的集合<br>Now i think of a module as a collection of related functions.</p>
<p>我们将要通过圆点标记法来使用函数( . )<br>and we’re going to refer to the functions using dot notation.</p>
<p>一种特殊的模块,模块中包括了类或者它们本身就是类<br>a particular kind of module,and those are the modules that include classes or that are classes.</p>
<p>在这个问题上我们将要强调要在面向对象编程的环境中使用类<br>In this subject we’re going to emphasize using classes in the context of what’s called object-oriented programming.</p>
<p>data abstractions<br>Abstract data type</p>
<p>对象就是数据和函数的集合<br>An object is a collection of data and functions.<br>这里关键思想就是将函数和操作数据的函数绑在一起成为一个东西<br>The key idea here is to bind together the data and the functions that operate on that data as a single thing.</p>
<p>user defind types<br>数据与函数的结合是面向对象编程的核心<br>This combining of data and functions on that data is a very essence of object-oriented programming.</p>
<p>we also call it encapsulation 封装</p>
<p>消息传递 传递隐喻的消息<br>we talk about it in terms of message pass, a message passing metaphor.</p>
<p>one object can pass a message to another object and the receiving object responds by executing one of its methods on the object.</p>
<p>l.sort();<br>这个对象传递一个消息sort 这个消息让我们去找sort方案,然后应用到对象I<br>pass the object I the message sort,and that message says find the method sort,and apply it to the object I.</p>
<p>notion of an instance.<br>类是有相同特质对象的集合<br>A class is a collection of objects with characteristics in common.</p>
<p>and extend the language.</p>
<p><strong>15.Abstract data types,classes and methods</strong></p>
<p>Class ,a template for creating instances of an object.<br>类是创建对象实例的模板</p>
<p>浅意义上的相等和深意义上的相等<br>shallow equality and deep equality.</p>
<p>测试浅意义上的相等<br>The first thing is testing shallow equality.<br>它本质是说,对于给定的两个东西它们是不是指向同一个引用<br>is essentially saying,given 2 things,do they point to exactly the same referent?<br>看看这两个是否指向内存中的同一位置.<br>is saying,do these things point to exactly the same spot in memory.</p>
<p>建立不同的版本的这些东西的一个模板<br>that’s going to let us build versions of these things.</p>
<p>这里有一个奇怪的额外的名为self的变量<br>There’s this weird extra variable in there called self.</p>
<p>当我创建了一个实例我应该能够获得那些特性化这个实例的东西<br>When i create a instance,i have to be able to get access to the things that characterize that instance.<br>这里特性化这个实例的东西是内在的详细说明要做什么的参数<br>what characterizes an instance here,it’s the internal parameters that specify what is going on.</p>
<p><strong>init</strong>  –when we call it, create an instance<br>–use “self” to refer to that instance</p>
<p>init方法创建了一个指向这个实例的指针<br>Init create a pointer to the instance.</p>
<p>把self作为指向这个实例的指针传了进去<br>And then it needs to have access to that,so it calls it passing in self as the pointer to the instance.</p>
<p>init这个方法可以去访问内存中的这一块了 然后在这块内存里面<br>it says it has access to that piece in memory,and now inside of that piece of memory</p>
<p>self will always point to the particular instance.<br>same other programming languages do not provide that pointer.</p>
<p>Methods - can access values of the specific instance.</p>
<p>Data hiding<br>一个人仅仅可以通过定义好的方法来访问实例变量</p>
<ul>
<li>one can only access instance values through defined methods.</li>
</ul>
<p>python doesnot do this</p>
<p><strong>str</strong> - printed representation,it converts things into a string type.代表打印,将东西转为字符串格式.</p>
<p><strong>cmp</strong> - doing comparisons.</p>
<p>Operate overloading</p>
<p>Instance (</p>
<ul>
<li>methods</li>
<li>fields<br>)<br>attributes</li>
</ul>
<p>与实例相关联的是方法和域,它们统称为实例的属性<br>associated with an instance,we have both methods and fields.these are both called attributes of the instance.</p>
<p><strong>16.Encapsulation,inheritance,shadowing</strong></p>
<p>class<br>是一种将数据聚集起来的数据,这是模块/抽象的概念,在这里都把它们当作了原语<br>just trying to cluster data together.And this is a notion of modularity slash abstraction,where i’m treating them as primitives.</p>
<p>类将会创建实例,也就是该结构的特例<br>Class is used to make instances,meaning particular versions,of that structure</p>
<p>当我们调用person类定义的时候,它就创建了一个实例<br>when we called the class definition,person,it create an instance,there it is.</p>
<p>把它想成是指向内存中一点的指针,然后我们所做的是初始化成员函数<br>Thinkd of it as a pointer to a spot in memory,and then what  we do is,then we call,or find that init method.</p>
<p>初始化(init)成员函数<br>And the first argument self,points to the instance.</p>
<p><strong>17.Computational models:random walk simulation</strong></p>
<p>探索一些随机性<br>Dealing with &amp; exploiting randomness</p>
<p>随机指标  它们包含了一些随机性<br>Stochastic they incorporate randomness.</p>
<p>弄清数据的概念<br>Making sense of data</p>
<p>当我们在 再说一次 在对世界进行建模 我们发现里面有大量的数据<br>As we look at,again,modeling the world,what we discover,there’s a lot of data out there</p>
<p>评价答案的质量<br>Evalvating quality of answers</p>
<p>从简单的地方入手<br>Start Simple</p>
<p>也就是从一些对真实问题的简单估算开始<br>So start with some simple approximation to the real problem.</p>
<p>我会去假设 就像我们之前做的一样 我们有一个笛卡尔坐标系,玩家是站在一片像坐标纸一样的场地上<br>And I’m going to assume,as we’ve seen before,that we have Cartesian  coordinates and that the player is standing on a field that has been cut  to resemble a piece of graph paper.</p>
<p>只能选择四个方向中的一个:北 南 东或西<br>only go in one of four directions: north, south, east, or west.</p>
<p>然后对着一个方向迈出一步.不失去一般性<br>student is here and takes a step in one direction or another.without loss of generality</p>
<p>有四分之三的几率学生离出发点更远了<br>three times out of four you get further away.</p>
<p>模拟无规则运动<br>Simulate random walk</p>
<p>模拟 也就是我们去尝试着建立一个假扮成真实世界的模型然后模拟一些东西<br>Simulation where we try build the model that pretends it’s the real world and simulates what goes on,and a random walk.</p>
<p>来尝试着给你们做一个实例分析<br>Trying to give you a case study</p>
<p>开始去想象合适的抽象数据是什么<br>Thinking about what might be the appropriate data abstractions.</p>
<p>位置<br>Location</p>
<p>Compass point</p>
<p>Field</p>
<p>Drunk</p>
<p>罗经点的数据抽象来代表这个学生会朝北 南 东 西 四个方向走<br>compass point to capture the notion that the student is going north,south,east,or west.</p>
<p>把位置和方向的概念分离开了<br>separate the notion of direction</p>
<p>因此可以把它当作是一个完全的笛卡尔平面而这个人所处的位置就是平面上的一个点<br>So think of that as the whole Cartesian plain,as opposed to a point in the plane,which is what the location is.<br>因为全部问题是关于这个喝醉的人现在在哪儿的<br>since after all the whole problem talks about where the drunk is.</p>
<p>pseudo random</p>
<p><strong>18.Presenting simulation results,Pylab,plotting</strong></p>
<p>执行一个模拟实验的内循环<br>1) we start with an inner loop that simulates one trail.</p>
<p>然后我会把这个内循环”包”在执行恰当数量的实验的循环中<br>2)And then i’ll quoto,enclose,unquote the inner loop in another loop that conducts an appropriate number of trials.</p>
<p>计算实验的统计数据并将它们表示出来<br>3)Calculate and present some relevant statistics about the trials.</p>
<p><strong>19.Biased random walks,distributions</strong></p>
<p>有偏的随机漫步</p>
<p>Polymorphism 多态性</p>
<p>尝试创建一个代表性的场景<br>Generate a sample of representative scenarios.</p>
<p>因为穷举所有可能的洲是不大可能的<br>Because an exhaustive enumeration of all possible states would be impossible.</p>
<p>你可以穷举空间,然后看看它会得到什么结果<br>you can exhaustively enumerate the space and then see what’s going on.</p>
<p>Experimental device</p>
<p>I’m running an experiment designed to give me some information about the real world.</p>
<p>他们都是描述性的而非预测性的<br>they are typically descriptive not presciptive.</p>
<p>they describe a situation,they don’t tell you what the answer is.</p>
<p>模拟并不是一个最优化过程<br>a simulation is not an optimization procedure.When we looked at  optimization,that was prescriptive.We ran an optimization algorithm,and  it gives us the best possible solution.</p>
<p><strong>20.Monte Carlo simulations,estimating pi</strong></p>
<p>将模拟模型进行分类的不同途径<br>classify simulation models.<br>是随机还是确定性的问题<br>it’s stochastic or deterministic</p>
<p>静态还是动态<br>static vs dynamic time</p>
<p>第三个分歧就是离散和连续<br>A third dichotomy is discrete vs continuous.</p>
<p>21.Validating simulation results,curve fitting,linear regression<br>验证模拟结果,曲线拟合,线性回归</p>
<p>How many samples?<br>How accurate?<br>Biased sample</p>
<p>Data<br>Models that explain data<br>Consequences that follow from the models</p>
<p>Whenever we try and fit something,We need some sort of an objective function.</p>
<p>Least squares fit</p>
<p>进行最优化的方式,实际上还有更有效率的办法<br>It turns out that for this particular optimization,there’s something more efficient.</p>
<p>对这种问题有一个闭型解决方案<br>there is a closed form way of attacting this</p>
<p>线性回归<br>Linear regression</p>
<p>因变量y和自变量的关系是这些参数的线性函数<br>the relationship of the dependent variable y to the independent variables is assumed to be a linar function of the parameters.</p>
<p>R2 - coefficient of determination</p>
<p>R2 = 1 - EE/Dr</p>
<p>就是它通过模型中的变量去尝试获取因变量的比例<br>It’s attempting to capture the proportion of the response variation explained by the variables in the model.</p>
<p>所以你可以看到一部分值的改变是因为变量值的改变<br>So you’ll have some amount of variation that is explained by changing the values of the variables</p>
<p>我有一些预测数据 如果你愿意<br>So e e is going to be the errors in the estimation.</p>
<p>r2 = 0.9</p>
<p>基本上这些变量90%的改变都能靠这个模型来解释<br>approximately 90 percent of the variation in the variables can be explained by the model.</p>
<p>潜在变量<br>lurking variable</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/理论/">理论</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/算法/">算法</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/编程/">编程</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/语言/">语言</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-css3-2d-e5-92-8c3d-e7-9f-a9-e9-98-b5-e7-9a-84-e5-8e-9f-e7-90-86-css3-2d-and-3d-matrix" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/10/14/css3-2d-e5-92-8c3d-e7-9f-a9-e9-98-b5-e7-9a-84-e5-8e-9f-e7-90-86-css3-2d-and-3d-matrix/" class="article-date">
  <time datetime="2011-10-14T14:33:52.000Z" itemprop="datePublished">2011-10-14</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/CSS-amp-HTML/">CSS &amp; HTML</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/10/14/css3-2d-e5-92-8c3d-e7-9f-a9-e9-98-b5-e7-9a-84-e5-8e-9f-e7-90-86-css3-2d-and-3d-matrix/">CSS3 2D和3D矩阵的原理_CSS3 2D and 3D matrix</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>2d的变形:</p>
<p><code>-webkit-transform: matrix3d(1, 0, 0, 1);</code></p>
<p><code>这里的`</code>(1, 0, 0, 1)是两个向量a(1,0) b(0,1),向量a是x轴方向上的,向量b是y轴方向上的.向量值的变化使得图形在方向和大小上有所改变.<br>`</p>
<p><code>3d的变形:</code></p>
<p><code>-webkit-transform: matrix3d(1, 0, 0, 0,   0, 1, 0, 0,   0, 0, 1, 0,   0, 0, 0, 1);</code></p>
<p><code>这里的16个</code>值描述了3个向量：</p>
<p>x轴方向 a(x1,x2,x3)  y轴方向 b(y1,y2,y3)  z轴方向 c(z1,z2,z3).</p>
<p>T行则重新定义了 x,y,z轴方向的对象(object)位置，即其在3d空间中的坐标.</p>
<p>W列则决定各个轴的透视效果(perspective-projection),它是我们沿着相关轴的视角(viewpoint).具体与<a href="http://zh.wikipedia.org/wiki/%E9%BD%90%E6%AC%A1%E5%9D%90%E6%A0%87" target="_blank" rel="noopener">齐次坐标</a>(Homogeneous Coordinates)有关.</p>
<p><table></table></p>
<p><tbody></tbody></p>
<p><tr></tr></p>
<p><td>x</td></p>
<p><td>x</td></p>
<p><td>x</td></p>
<p><td>Wx</td><br></p>
<p><tr></tr></p>
<p><td>y</td></p>
<p><td>y</td></p>
<p><td>y</td></p>
<p><td>Wy</td><br></p>
<p><tr></tr></p>
<p><td>z</td></p>
<p><td>z</td></p>
<p><td>z</td></p>
<p><td>Wz</td><br></p>
<p><tr></tr></p>
<p><td>Tx</td></p>
<p><td>Ty</td></p>
<p><td>Tz</td></p>
<p><td>W</td><br><br><br><br>原文地址:<a href="http://www.eleqtriq.com/2010/05/css-3d-matrix-transformations/" target="_blank" rel="noopener">http://www.eleqtriq.com/2010/05/css-3d-matrix-transformations/</a></p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/CSS/">CSS</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/CSS-3/">CSS 3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/语言/">语言</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-e8-af-ad-e4-b9-89-e7-bd-91-e4-b8-8e-e7-a4-be-e4-bc-9a-e5-8c-96-e7-bd-91-e7-bb-9c-e7-9a-84-e7-bb-93-e5-90-88-e4-b8-8e-e6-bc-94-e5-8c-96-semantic-web-combine-with-social-network-to-evolve" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/10/07/e8-af-ad-e4-b9-89-e7-bd-91-e4-b8-8e-e7-a4-be-e4-bc-9a-e5-8c-96-e7-bd-91-e7-bb-9c-e7-9a-84-e7-bb-93-e5-90-88-e4-b8-8e-e6-bc-94-e5-8c-96-semantic-web-combine-with-social-network-to-evolve/" class="article-date">
  <time datetime="2011-10-06T16:06:18.000Z" itemprop="datePublished">2011-10-07</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/web-development/">web development</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/10/07/e8-af-ad-e4-b9-89-e7-bd-91-e4-b8-8e-e7-a4-be-e4-bc-9a-e5-8c-96-e7-bd-91-e7-bb-9c-e7-9a-84-e7-bb-93-e5-90-88-e4-b8-8e-e6-bc-94-e5-8c-96-semantic-web-combine-with-social-network-to-evolve/">语义网与社会化网络的结合与演化_Semantic web combine with Social network to evolve</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Abstract-摘要"><a href="#Abstract-摘要" class="headerlink" title="Abstract 摘要"></a>Abstract 摘要</h3><p>社会化网络构建了一个与现实社会对应的人际网络生态圈,但是基于web本身的缺陷,其给我们生活带来越来越多的问题.如信息泛滥,线上线下时间的平 衡,共同目标人群的聚合,社交对教育的影响等等.而语义网则是在传统web上加入关联数据等特性使得人工智能的网络成为可能,那么其可能在某些方面为社会 化网络的优化和发展起到积极作用.</p>
<h3 id="Introduction-简介"><a href="#Introduction-简介" class="headerlink" title="Introduction 简介"></a>Introduction 简介</h3><p>本文主要由两大部分组成,一大部分是关于社会化网络的种种缺陷和问题,另一部分是关于如何利用语义网的概念来改善和弥补这些不足,而让其更加与现实社会关系密切并更方便地为人们服务.主要章节有:</p>
<p>1.社会化网络生态模型及缺陷</p>
<p>2.社会化网络中的心理学</p>
<p>3.社会化网络中的教育问题</p>
<p>4.为什么关联数据</p>
<p>5.人工智能的web能做什么</p>
<p>6.语义的社会化网络:智能的生态模型</p>
<h3 id="社会化网络生态模型及缺陷"><a href="#社会化网络生态模型及缺陷" class="headerlink" title="社会化网络生态模型及缺陷"></a>社会化网络生态模型及缺陷</h3><p>目前的社会化网络模型分为两种:强制双向连接模型和单双向任意连接模型,强制双向连接模型信息传递方式为双向互传,并且信息范围只存在于组内(或者说圈内).单双向任意连接模型则允许信息进行单向或双向传递,并且允许接收点进行信息传递,即传播扩散.</p>
<p>以上两种网络模型属于现实社会网络模型的部分实现,或者说其映射了现实社会网络的一部分,前者基于朋友或者好友的分享与互动这个个人社会活动,后者基于个人即时分享并传播这个生活中的例子(比如说演讲).</p>
<p>就单个个体所在网络来说,单个个体处于一个个体数量为n的集合里面,并且通过信息传递建立连接,信息单向传递的称为单向连接,双向传递称为双向连 接,单向连接数最大为:n(n-1)/2.而双向的最大连接数为:n(n-1).同时n趋向无穷大时,无论单双向连接Lim(n-&gt;∞) f(n)  = n*n;</p>
<p>而最小传播连接数指在所有点都建立连接所需的最少连接,它有两种连接方式,一种是环连接,还有一种为发散状连接.其单向最小连接为n-1,而双向则为2(n-1).</p>
<p>因此,在一组存在完整连接的n个点中(不存在孤点),如果每一个点发出一条信息,在不同连接状态,其值与连接数f(n)相同.也就是说,在存在关联的社会化网络中,如果一个人际圈中有n个用户,每个用户共享一条信息,那么产生的有效信息数在n到n*n之间.</p>
<p>当一个个小型集合通过1到n个交叉个体产生关联,就形成了完善的社会化网络生态圈,并且假设信息通过这1到n个交叉个体进行发散,每组平均人数为m,传播次数为n,若m&gt;=3,n&gt;=1体系成立,单条信息进行发散,总传递接收次数约为 f(m,n)=m+m<sup>2</sup>+ … +m<sup>n</sup>;  若信息传播模式为双向则接收次数约为 f(m,n)=2<em>m+2</em>m<sup>2</sup>+ … +2*m<sup>n</sup>;</p>
<p>并且由此可以得出,当连接为双向时：</p>
<p>传播起始点，接收重复信息(m-1)次,传播重复信息0次.</p>
<p>中间点接收重复信息(m+1)次,传播重复信息(m-1)次.</p>
<p>边界点(末端)接收重复信息0次,传播重复信息0次.</p>
<p>总传播重复次数约为: f(n) = m<sup>2</sup> + m<sup>3</sup> + … +m<sup>n</sup>;(n&gt;=2),</p>
<p>在一组有连接的点中,一条信息被传递,传播次数介于m+ m<sup>2</sup>+ …+m<sup>n</sup> 与m+ 2<em>m<sup>2</sup>+ …+ 2</em>m<sup>n</sup>之间(m&gt;=3,n&gt;=1)</p>
<p>现在的社会化网络模型只是完成了信息的分享与传播,其对使用者之间的关系的定义是不确切的，对不同年龄和角色的使用者的帮助是有限的，对共同目标或 兴趣的用户聚合是不完善的,它是现实社会网络的子集，所以存在许许多多的缺陷,并且对信息本身的考虑也非常少,以至于使用者本身一直处于被动接受状态,对 信息传播带来的问题无法应对.所以目前的网络最迫切的是将用户最需要的信息第一时间送达,并且为用户屏蔽无效信息.并且一个理想的状态是,网络本身开始习 惯用户的喜好和特点,并进行按需呈现信息.</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/理论/">理论</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/社会化网络/">社会化网络</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-javacript-e4-b8-adprototype-e7-9a-84-e5-ae-9e-e4-be-8b-e5-8c-96-prototype-instantiate-in-javacript" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/09/04/javacript-e4-b8-adprototype-e7-9a-84-e5-ae-9e-e4-be-8b-e5-8c-96-prototype-instantiate-in-javacript/" class="article-date">
  <time datetime="2011-09-03T16:04:52.000Z" itemprop="datePublished">2011-09-04</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/javascript-amp-Ajax/">javascript &amp; Ajax</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/09/04/javacript-e4-b8-adprototype-e7-9a-84-e5-ae-9e-e4-be-8b-e5-8c-96-prototype-instantiate-in-javacript/">javacript中prototype的实例化_prototype instantiate in javacript</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>在Javascript高级程序设计中有讲到使用动态原型(dynamic prototyping)来构建对象,其有讲到原型的赋值在判断语句里面不可行,但是其却没有讲根本原因</p>
<p>function Polygon(iSides) {<br>this.sides = iSides;<br>if (typeof Polygon._initialized == “undefined”) {<br>Polygon.prototype.getArea = function () {<br>return 0;<br>};<br>Polygon._initialized = true;<br>}<br>}<br>function Triangle(iBase, iHeight) {<br>Polygon.call(this, 3);<br>this.base = iBase;<br>this.height = iHeight;<br>if (typeof Triangle._initialized == “undefined”) {<br><strong>Triangle.prototype = new Polygon();</strong><br>Triangle.prototype.getArea = function () {<br>return 0.5 <em> this.base </em> this.height;<br>};<br>Triangle._initialized = true;<br>}<br>}</p>
<p>其有讲到原因:</p>
<p>The previous code illustrates both Polygon and Triangle defined using  dynamic prototyping. The mistake is in the highlighted line, where  Triangle.prototype is set. Logically, this is the correct location;<br>but functionally, it doesn’t work. Technically, <strong>by the time that code is run, the object is already instantiated and tied to the original prototype object. </strong>Although  changes to that prototype object are reflected properly with very late  binding, replacing the prototype object has no effect on that object.  Only future object instances reflect the change, making the first  instance incorrect.</p>
<p>这表明prototype对象是在代码执行之前进行实例化的,有文章说是在解析期进行实例化的,但是个人比较奇怪的是为什么在调用两次才真正让原型赋值成功:</p>
<p>var temp1 = new Triangle(2,3);<br>var temp2 = new Triangle(4,5);<br>alert(temp2.getArea());</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Structure/">Structure</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/javascript/">javascript</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/编程/">编程</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/语言/">语言</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-javascript-e4-b8-ad-e5-af-b9-e8-b1-a1-e7-bb-a7-e6-89-bf-inheritance-in-javascript" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/08/29/javascript-e4-b8-ad-e5-af-b9-e8-b1-a1-e7-bb-a7-e6-89-bf-inheritance-in-javascript/" class="article-date">
  <time datetime="2011-08-28T16:03:35.000Z" itemprop="datePublished">2011-08-29</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/javascript-amp-Ajax/">javascript &amp; Ajax</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/08/29/javascript-e4-b8-ad-e5-af-b9-e8-b1-a1-e7-bb-a7-e6-89-bf-inheritance-in-javascript/">javascript中对象继承_inheritance in javascript</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>In javascript, the inheritance method is so different with java,and some note here is to summary it.</p>
<p>Methods of inheritance<br>As usual with ECMAScript, you have more than one way to implement  inheritance. This is because inheritance in JavaScript isn’t explicit;  it’s emulated. This means that the interpreter doesn’t handle all the  inheritance details. It is up to you, as the developer, to handle  inheritance in a way that is most appropriate for your situation.</p>
<p><strong>Object masquerading</strong></p>
<p>function ClassA(sColor) {<br>this.color = sColor;<br>this.sayColor = function () {<br>alert(this.color);<br>};<br>}</p>
<p>function ClassB(sColor) {<br>this.newMethod = ClassA;<br>this.newMethod(sColor);<br>delete this.newMethod;<br>}</p>
<p>function ClassB(sColor, sName) {<br>this.newMethod = ClassA;<br>this.newMethod(sColor);<br>delete this.newMethod;<br>this.name = sName;<br>this.sayName = function () {<br>alert(this.name);<br>};<br>}</p>
<p>the this keyword references the currently created object in a  constructor; in a method,however, this points to the owning object. The  theory is that treating ClassA as a regular function instead of as a  constructor establishes a type of inheritance.</p>
<p>but in java,the inheritance is extend the ancestors’ all method.it looks like:</p>
<p>public class A{</p>
<p>…</p>
<p>}</p>
<p>public class B extends A{</p>
<p>…</p>
<p>}</p>
<p>and then we can use call() to replace the inheritance:</p>
<p>function ClassB(sColor, sName) {<br>ClassA.call(this, sColor);<br>this.name = sName;<br>this.sayName = function () {<br>alert(this.name);<br>};<br>}</p>
<p>also apply() can use to reach this effect:</p>
<p>function ClassB(sColor, sName) {<br>ClassA.apply(this, new Array(sColor));<br>this.name = sName;<br>this.sayName = function () {<br>alert(this.name);<br>};<br>}</p>
<p>But i have a question,why javascript use call and apply to simulate  object inheritance.And also why not make a extends pattern and it will  looks like:</p>
<p>function ClassB extends ClassA(sColor, sName) {<br>this.name = sName;<br>this.sayName = function () {<br>alert(this.name);<br>};<br>}</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Structure/">Structure</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/javascript/">javascript</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/语言/">语言</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-css2-e4-b8-ad-e7-9a-84-e5-8f-af-e8-a7-86-e5-8c-96-e6-a0-bc-e5-bc-8f-e6-a8-a1-e5-9e-8b2-visual-fomatting-model-in-css22" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/08/19/css2-e4-b8-ad-e7-9a-84-e5-8f-af-e8-a7-86-e5-8c-96-e6-a0-bc-e5-bc-8f-e6-a8-a1-e5-9e-8b2-visual-fomatting-model-in-css22/" class="article-date">
  <time datetime="2011-08-18T16:02:19.000Z" itemprop="datePublished">2011-08-19</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/CSS-amp-HTML/">CSS &amp; HTML</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/08/19/css2-e4-b8-ad-e7-9a-84-e5-8f-af-e8-a7-86-e5-8c-96-e6-a0-bc-e5-bc-8f-e6-a8-a1-e5-9e-8b2-visual-fomatting-model-in-css22/">CSS2中的可视化格式模型(2)_Visual fomatting model in CSS2(2)</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="9-7-‘display’-’position’和’float’间的相互关系-Relationships-between-‘display’-‘position’-and-‘float’"><a href="#9-7-‘display’-’position’和’float’间的相互关系-Relationships-between-‘display’-‘position’-and-‘float’" class="headerlink" title="9.7 ‘display’,’position’和’float’间的相互关系 Relationships between ‘display’, ‘position’, and ‘float’"></a>9.7 ‘display’,’position’和’float’间的相互关系 Relationships between ‘display’, ‘position’, and ‘float’</h3><p>影响盒子的生成和布局的三个属性——‘display’,’position’和’float’——间的相互关系如下:</p>
<ol>
<li>如果’display’值为’none’,那么’position’和’float’无效,元素不生成盒子.</li>
<li>否则,如果’postion’值为’absolute’或者’fixed’,盒子绝对地定位’float’计算的值为’none’,并且      display根据下面的表格进行设定.盒子的位置由’top’, ‘right’, ‘bottom’和’left’属性和包含块决定.</li>
<li>否则,如果’float’的值不是’none’,该盒子是浮动的,且’display’值根据下面的表格进行设定.</li>
<li>否则,如果元素是根元素,’display’值根据下面的表格进行设定,除了其在CSS2.1里面没有定义是否’list-item’的指定值成为’block’或者’list-item’计算值.</li>
<li>否则,应用指定的其它’display’属性.<table border="1"><br><tbody><br><tr><br><th>指定值 Specified value</th><br><th>计算值 Computed value</th><br></tr><br><tr><br><td>inline-table</td><br><td>table</td><br></tr><br><tr><br><td>inline, table-row-group, table-column,       table-column-group, table-header-group, table-footer-group, table-row,       table-cell, table-caption, inline-block</td><br><td>block</td><br></tr><br><tr><br><td>others</td><br><td>same as specified</td><br></tr><br></tbody><br></table>

</li>
</ol>
<h3 id="9-8-常规流向，浮动和绝对定位的对比-Comparison-of-normal-flow-floats-and-absolute-positioning"><a href="#9-8-常规流向，浮动和绝对定位的对比-Comparison-of-normal-flow-floats-and-absolute-positioning" class="headerlink" title="9.8 常规流向，浮动和绝对定位的对比 Comparison of normal flow, floats, and absolute positioning"></a>9.8 常规流向，浮动和绝对定位的对比 Comparison of normal flow, floats, and absolute positioning</h3><p>为了演示常规流向，相对定位，浮动和绝对定位间的区别，我们提供一系列的例子，它们都基于如下的HTML片段:</p>
<p>&lt;!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0//EN”&gt;<br>&lt;HTML&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;Comparison of positioning schemes&lt;/TITLE&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY&gt;<br>&lt;P&gt;Beginning of body contents.<br>&lt;SPAN id=”outer”&gt; Start of outer contents.<br>&lt;SPAN id=”inner”&gt; Inner contents.&lt;/SPAN&gt;<br>End of outer contents.&lt;/SPAN&gt;<br>End of body contents.<br>&lt;/P&gt;<br>&lt;/BODY&gt;<br>&lt;/HTML&gt;</p>
<p>在文档中，我们假定有如下规则:</p>
<p>body { display: block; font-size:12px; line-height: 200%;<br>width: 400px; height: 400px; }<br>p    { display: block;}<br>span { display: inline; }</p>
<h4 id="9-8-1-常规流向-Normal-flow"><a href="#9-8-1-常规流向-Normal-flow" class="headerlink" title="9.8.1 常规流向 Normal flow"></a>9.8.1 常规流向 Normal flow</h4><p>考虑如下的outer和inner的CSS声明，它们并不改变<a href="http://www.w3.org/TR/CSS21/visuren.html#normal-flow" target="_blank" rel="noopener">常规流</a>盒子:</p>
<p>#outer { color: red; }</p>
<p>#inner { color: blue; }</p>
<p>P元素包含所有的行内内容：<a href="http://www.w3.org/TR/CSS21/visuren.html#anonymous" target="_blank" rel="noopener">匿名行内文本</a>以及两个SPAN元素。因此所有的内容将在一个行内格式化内容中得到排列，包含在一个由P元素生成的包含块中，看起来如下图:</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-generic.png" alt="Image illustrating the normal flow of text between parent and sibling boxes."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-generic-desc.html" title="Long description for normal flow example" target="_blank" rel="noopener">[D]</a></p>
<h4 id="9-8-2-相对定位-Relative-positioning"><a href="#9-8-2-相对定位-Relative-positioning" class="headerlink" title="9.8.2 相对定位 Relative positioning"></a>9.8.2 相对定位 Relative positioning</h4><p>要看到<a href="http://www.w3.org/TR/CSS21/visuren.html#relative-positioning" target="_blank" rel="noopener">相对定位</a>的效果,我们规定:</p>
<p>#outer { position: relative; top: -12px; color: red; }</p>
<p>#inner { position: relative; top: 12px; color: blue; }</p>
<p>文本正常排列直到outer元素.outer的文本在第一行结尾排列到它的正常流向的位置和尺寸.然后包含文字行内盒(分三行排列)移动了’-12px’单位(向上).</p>
<p>inner的内容,作为outer的子元素,正常地应该紧接”of outer contents”排列(在第1.5行).不过,inner的内容自身相对outer内容偏移’12px’(向下),而回到它原来的位置第二行.</p>
<p>注意跟随在outer之后的内容并不受outer相对定位的影响.</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-relative.png" alt="Image illustrating the effects of relative positioning on a box"> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-relative-desc.html" title="Long description for relative flow example" target="_blank" rel="noopener">[D]</a></p>
<p>还要注意,如果outer的偏移是’-24px’,那么outer的文本和主体文本会重合.</p>
<h4 id="9-8-3-浮动一个盒-Floating-a-box"><a href="#9-8-3-浮动一个盒-Floating-a-box" class="headerlink" title="9.8.3 浮动一个盒 Floating a box"></a>9.8.3 浮动一个盒 Floating a box</h4><p>现在考虑<a href="http://www.w3.org/TR/CSS21/visuren.html#floats" target="_blank" rel="noopener">浮动</a>inner元素的效果,我们通过如下规则将它的文本向右浮动:</p>
<p>#outer { color: red; }</p>
<p>#inner { float: right; width: 130px; color: blue; }</p>
<p>文本正常排列直到inner盒,它从流向中脱离并浮动到右边距(它的’width’是显式指定的).浮动左边的行盒被缩短,文档的其余文本流入里面.</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-float.png" alt="Image illustrating the effects of floating a box."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-float-desc.html" title="Long description of example illustrating floating" target="_blank" rel="noopener">[D]</a></p>
<p>要显示’clear’属性的效果，我们在例子中加入一个同胞元素:</p>
<p>&lt;!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0//EN”&gt;<br>&lt;HTML&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;Comparison of positioning schemes II&lt;/TITLE&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY&gt;<br>&lt;P&gt;Beginning of body contents.<br>&lt;SPAN id=outer&gt; Start of outer contents.<br>&lt;SPAN id=inner&gt; Inner contents.&lt;/SPAN&gt;<br>&lt;SPAN id=sibling&gt; Sibling contents.&lt;/SPAN&gt;<br>End of outer contents.&lt;/SPAN&gt;<br>End of body contents.<br>&lt;/P&gt;<br>&lt;/BODY&gt;<br>&lt;/HTML&gt;</p>
<p>和如下规则：</p>
<p>#inner { float: right; width: 130px; color: blue; }</p>
<p>#sibling { color: red; }</p>
<p>这就使inner盒和以前一样向右浮动，而文档的其余文本流入空出的地方：</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-clear.png" alt="Image illustrating the effects of floating a box without setting the clear property to control the flow of text around the box."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-clear-desc.html" title="Long description of example illustrating floating without clear" target="_blank" rel="noopener">[D]</a></p>
<p>但是,如果同胞元素的’clear’属性设置为’right’(即,生成的同胞盒不接受在右边有浮动盒相邻的位置),则同胞的内容在浮动之下开始排列:</p>
<p>#inner { float: right; width: 130px; color: blue; }</p>
<p>#sibling { clear: right; color: red; }</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-clear2.png" alt="Image illustrating the effects of floating an element with setting the clear property to control the flow of text around the element."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-clear2-desc.html" title="Long description of example illustrating floating with clear" target="_blank" rel="noopener">[D]</a></p>
<h4 id="9-8-4-绝对定位-Absolute-positioning"><a href="#9-8-4-绝对定位-Absolute-positioning" class="headerlink" title="9.8.4 绝对定位 Absolute positioning"></a>9.8.4 绝对定位 Absolute positioning</h4><p>最后，我们考虑<a href="http://www.w3.org/TR/CSS21/visuren.html#absolute-positioning" target="_blank" rel="noopener">绝对定位</a>的效果。考虑如下的outer和inner的CSS声明：</p>
<p>#outer {<br>position: absolute;<br>top: 200px; left: 200px;<br>width: 200px;<br>color: red;<br>}</p>
<p>#inner { color: blue; }</p>
<p>这就使outer盒的顶部的定位基于它的包含块。定位盒的包含块由最靠近的定位的父辈创建(或者，如果不存在这样的父辈，则采用<a href="http://www.w3.org/TR/CSS21/visudet.html#containing-block-details" target="_blank" rel="noopener">初始包含块</a>，就像在本例中)。outer盒的顶部在包含块顶部  ‘200px’之下，左边在包含块左边’200px’。outer盒的子盒的排列相对于outer盒正常排列。</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-absolute.png" alt="Image illustrating the effects of absolutely positioning a box."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-absolute-desc.html" title="Long description for example illustrating absolute positioning" target="_blank" rel="noopener">[D]</a></p>
<p>下面的例子展示了一个相对定位盒子中的一个绝对定位的子盒。尽管outer父盒并没有实际偏移，设置它的’position’属性为’relative’       意味着这个盒可以作为定位派生内容的包含块。由于outer盒是一个行内盒并跨越几行分布，第一个行内盒的顶和左边(在图形中用粗点线标出)作为      ‘top’和’left’偏移的参考.</p>
<p>#outer {<br>position: relative;<br>color: red;<br>}</p>
<p>#inner {<br>position: absolute;<br>top: 200px; left: -100px;<br>height: 130px; width: 130px;<br>color: blue;<br>}</p>
<p>结果可能看起来是这样的:</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-abs-rel.png" alt="Image illustrating the effects of absolutely positioning a box with respect to a containing block."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-abs-rel-desc.html" title="Long description for example illustrating positioning with respect to a positioned ancestor" target="_blank" rel="noopener">[D]</a></p>
<p>如果我们不定位outer盒：</p>
<p>#outer { color: red }</p>
<p>#inner {<br>position: absolute;<br>top: 200px; left: -100px;<br>height: 130px; width: 130px;<br>color: blue;<br>}</p>
<p>inner盒的包含块成为初始包含块(在我们的例子中).下面的例子展示了这种情况下.inner盒最终的位置.</p>
<p><img src="http://www.w3.org/TR/CSS21/images/flow-static.png" alt="Image illustrating the effects of absolutely positioning a box with respect to a containing block established by a normally positioned parent."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/flow-static-desc.html" title="Long description illustrating absolute positioning with respect to the initial containing block" target="_blank" rel="noopener">[D]</a></p>
<p>相对和绝对定位可以用来实现变更栏，下例是这一实现的演示。考虑如下文档:</p>
<p>&lt;P style=”position: relative; margin-right: 10px; left: 10px;”&gt;<br>I used two red hyphens to serve as a change bar. They<br>will “float” to the left of the line containing THIS<br>&lt;SPAN style=”position: absolute; top: auto; left: -1em; color: red;”&gt;–&lt;/SPAN&gt;<br>word.&lt;/P&gt;</p>
<p>可能呈现为:</p>
<p><img src="http://www.w3.org/TR/CSS21/images/changebar.png" alt="Image illustrating the use of floats to create a changebar effect."> <a href="http://www.w3.org/TR/CSS21/images/longdesc/changebar-desc.html" title="Long description for change bar example" target="_blank" rel="noopener">[D]</a></p>
<p>首先，该段落(包含块在图形中也显示出来)正常排列.然后它从包含块的左边偏移’10px’(从而为该偏移保留了’10px’的右边距).两个作为变更栏的连字号从常规流向中脱离，并定位在当前行(由于’top:     auto’).相对它的包含块(由最终位置的P创建)的左边移动’-1em’.结果是变更栏看上去”浮动”在当前行的左边.</p>
<h3 id="9-9-分层的呈现-Layered-presentation"><a href="#9-9-分层的呈现-Layered-presentation" class="headerlink" title="9.9 分层的呈现 Layered presentation"></a>9.9 分层的呈现 Layered presentation</h3><h4 id="9-9-1-指定堆叠层次-’z-index’属性-Specifying-the-stack-level-the-‘z-index’-property"><a href="#9-9-1-指定堆叠层次-’z-index’属性-Specifying-the-stack-level-the-‘z-index’-property" class="headerlink" title="9.9.1 指定堆叠层次:’z-index’属性 Specifying the stack level: the ‘z-index’ property"></a>9.9.1 指定堆叠层次:’z-index’属性 Specifying the stack level: the ‘z-index’ property</h4><p><strong>‘z-index’</strong><br>值：   auto | &lt;integer&gt; | inherit<br>初始值：   auto<br>适用于：   定位元素<br>可否继承：   否<br>百分比：   N/A<br>媒介：   图形</p>
<p>对于一个定位盒，’z-index’属性指定了：</p>
<p>当前堆叠内容中盒的堆叠层次。<br>该盒子是否生成局部堆叠内容。<br>取值的含义如下：</p>
<p><span style="text-decoration: underline;"><strong>&lt;integer&gt; </strong></span><br>该整数是生成的盒在当前堆叠内容中的堆叠层次。该盒也生成了一个局部堆叠内容，在其中它的堆叠层次是’0’。<br><strong>auto </strong><br>生成的盒在当前堆叠内容中的堆叠层次和它的父盒相同。该盒不生成新的局部堆叠内容。</p>
<p>在该章节中,表达式”in front of”意思是更接近用户因为用户面对屏幕.</p>
<p>在CSS 2.1中,每个盒子在3个维度(dimensions)有个定位.除了水平和垂直的位置,盒子沿着”z-轴”展现并且被格式化成一个在其他的上面.当盒子在视觉上重叠了Z-轴定位特别地重要.这个章节谈论盒子怎样沿着z-轴定位.</p>
<p>渲染的树绘到canvas上的顺序描述是依照堆叠上下文.堆叠上下文能包含更深层的堆叠上下文.一个堆叠上下文从它的父级堆叠上下文的观点来看是原子的;在其它堆叠上下文的盒子可能不干涉它的任何盒子.</p>
<p>每个盒子属于一个堆叠上下文.每个定位的盒子在给出的堆叠上下文有一个整数的堆叠级别,堆叠级别是它在相同堆叠上下文里面z-轴相对于其它堆叠级别的位  置.有较大堆叠级别的盒子总是会被格式化在较低堆叠级别盒子的前面.盒子可以有负的堆叠级别.盒子在同样的堆叠上下文中有同样的堆叠级别根据文档树顺序由  后到前堆放.</p>
<p>根元素形成根堆叠上下文.其它由任意定位的元素生成(包含相对定位元素)的堆叠上下文有一个可计算的’z-index’值不同于’auto’.堆叠上下文不一定与包含块相关.在未来CSS的等级,其它属性可以引入堆叠上下文,例如<a href="http://www.w3.org/TR/css3-color/#transparency" target="_blank" rel="noopener">‘opacity’</a><a href="http://www.w3.org/TR/CSS21/refs.html#ref-CSS3COLOR" target="_blank" rel="noopener">[CSS3COLOR]</a>.</p>
<p>在每个堆叠上下文中,下面的层在从后到前的顺序中绘出:</p>
<ol>
<li>background和元素的borders形成堆叠上下文.</li>
<li>子堆叠上下文有负的堆叠级别(大多是负的在前面).</li>
<li>流内,非行内级别,非定位的后代.</li>
<li>非定位的浮动.</li>
<li>流内,行内级别,非定位后代,包含inline tables和inline 块.</li>
<li>堆叠级别为0的子堆叠上下文和堆叠级别为0的定位后代.</li>
<li>子堆叠上下文有正的堆叠级别(最小的正数优先)<br>在每个堆叠上下文,定位元素的堆叠级数为0(第6层),非定位浮动(第4层),内联块(5层),还有inline table(5层),被绘制好像那些元素本身生成新的堆叠上下文,除了它们定位的后代和任意将是子堆叠上下文参与当前的堆叠上下文.</li>
</ol>
<p>该绘制顺序递归地应用到每个堆叠上下文.该堆叠上下文绘制顺序的描述构成<a href="http://www.w3.org/TR/CSS21/zindex.html" target="_blank" rel="noopener">附录E</a>详细规范定义的概述.</p>
<p>在下面的例子中，各个盒（以它们的”id”属性命名）的堆叠层次是:<br>“text2”=0，”image”=1，”text3”=2，”text1”=3。”text2”的堆叠层次从它的根盒子继承而来。其它的由’z-index’属性指定。</p>
<p>&lt;!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0//EN”&gt;<br>&lt;HTML&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;Z-order positioning&lt;/TITLE&gt;<br>&lt;STYLE type=”text/css”&gt;<br>.pile {<br>position: absolute;<br>left: 2in;<br>top: 2in;<br>width: 3in;<br>height: 3in;<br>}<br>&lt;/STYLE&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY&gt;<br>&lt;P&gt;<br>&lt;IMG id=”image”<br>src=”butterfly.gif” alt=”A butterfly image”<br>style=”z-index: 1”&gt;</p>
<p>&lt;DIV id=”text1”<br>style=”z-index: 3”&gt;<br>This text will overlay the butterfly image.<br>&lt;/DIV&gt;</p>
<p>&lt;DIV id=”text2”&gt;<br>This text will be beneath everything.<br>&lt;/DIV&gt;</p>
<p>&lt;DIV id=”text3”<br>style=”z-index: 2”&gt;<br>This text will underlay text1, but overlay the butterfly image<br>&lt;/DIV&gt;<br>&lt;/BODY&gt;<br>&lt;/HTML&gt;</p>
<p>本例演示了透明的概念。一个盒子的缺省行为是允许在它后面的盒子透过它内容中透明的区域而可见。本例中，每个盒子透明地覆盖它下面的盒子。这一行为可以通过使用某个现成的<a href="http://www.w3.org/TR/CSS21/colors.html#background-properties" target="_blank" rel="noopener">背景属性</a>而被重写。</p>
<h4 id="9-10-文本方向：’direction’及’unicode-bidi’属性"><a href="#9-10-文本方向：’direction’及’unicode-bidi’属性" class="headerlink" title="9.10 文本方向：’direction’及’unicode-bidi’属性"></a>9.10 文本方向：’direction’及’unicode-bidi’属性</h4><p><a href="http://www.w3.org/TR/CSS21/conform.html#conformance" target="_blank" rel="noopener">遵照</a>用户端不支持双向文本可以忽略’direction’和’unicode-bidi’属性在该章节描述.该例外包括用户端简单地从右至左渲染字符.因为一个系统上的字体包含它们但是不支持从右到左文本方向的概念.</p>
<p>在某些脚本中，文字是从右到左书写的。某些文档中，特别是以阿拉伯或希伯来文写成的文档中，以及一些混合语言的内容中，单一(视觉上显示的)块中文字的排列也有不同的方向。这一现象称为双向排列或简称为“双向”。</p>
<p>Unicode标准(<a href="http://www.w3.org/TR/CSS21/refs.html#ref-UNICODE" target="_blank" rel="noopener">[UNICODE]</a>,<a href="http://www.w3.org/TR/CSS21/refs.html#ref-UAX9" target="_blank" rel="noopener">[UAX9]</a>)      定义了一个复杂的算法来确定文字正确的方向。该算法包含了基于字符属性的隐式部分，以及对于嵌入和重写的显式控制。CSS2依赖这一算法来获得正确的双向 渲染。’direction’及’unicode-bidi’属性允许作者规定文档语言的元素和属性如何与该算法相匹配.</p>
<p>用户端支持双向文本必须应用Unicode双向算法到每个行内级别盒的序列且该序列不被强制(<a href="http://www.unicode.org/reports/tr9/#Bidirectional_Character_Types" target="_blank" rel="noopener">bidi class B</a>) 中断或者块边界打断.这个序列在双向算法中形成”paragraph”(段落)单元.该段落嵌入级别通过包含块的<a href="http://www.w3.org/TR/CSS21/visuren.html#propdef-direction" target="_blank" rel="noopener">‘direction’</a>属性的值进行设置而不是通过Unicode算法在步骤P2和P3中给出的启发式heuristic来设置.</p>
<p>由于文字的方向性取决于文档语言的结构和语意，在大多数情况下，这些属性应该只由文档类型描述（DTD）的设计者或特殊文档的作者使用。如果一个缺 省样式表指定了这些属性，作者和用户不应该指定重写它们的规则。一个常见的例外可能是，如果一个用户端在用户的要求下将犹太语（通常以希伯来字母写成）音 译为拉    丁字母时，用户端重写了双向表现。</p>
<p>HTML  4.0规范（[HTML40]，8.2节）定义了HTML元素的双向排列行为。一致的HTML用户端可能在作者和用户的样式表里忽略 ‘direction’和’unicode-bidi’属性。在<a href="http://www.w3.org/TR/CSS21/refs.html#ref-HTML4" target="_blank" rel="noopener">[HTML40]</a>中指定的那些可能产生双向行为的规则出现在<a href="http://www.w3.org/TR/CSS21/sample.html#bidi" target="_blank" rel="noopener">示例样式表</a>中。HTML  4.0规范也包含了有关双向排列事项的更多的信息。</p>
<p><strong>‘direction’ </strong><br>值：   ltr | rtl | inherit<br>初始值：   ltr<br>适用于：   所有元素，但参见描述<br>可否继承：   可<br>百分比：   N/A<br>媒介：   图形</p>
<p>该属性指定了块的基本书写方向，以及Unicode双向算法中嵌入和超越的方向（参见’unicode-bidi’）。另外，它还规定了表格列布局的方向，水平溢出的方向，以及块设置了’text-align: justify’时，最后一个不完全的行的位置。</p>
<p>该属性取值的含义如下：</p>
<p><strong>ltr </strong><br>左到右的方向。<br><strong>rtl </strong><br>右到左的方向。<br>要使’direction’属性对行内元素有影响，’unicode-bidi’属性的值必须是’embed’或’override’。</p>
<p><strong>注意.</strong>‘direction’属性指定给表格列元素时，并不被列内的单元格继承，这是因为列不存在于文档树中。因此，对于<a href="http://www.w3.org/TR/CSS21/refs.html#ref-HTML4" target="_blank" rel="noopener">[HTML4]</a>，11.3.2.1节中描述的”dir”属性的继承规则，CSS不可能很容易地保持.</p>
<p><strong>‘unicode-bidi’ </strong><br>值：   normal | embed | bidi-override | inherit<br>初始值：   normal<br>适用于：   所有元素，但参见描述<br>可否继承：   no<br>百分比：   N/A<br>媒介：   图形</p>
<p>该属性取值的含义如下：</p>
<p><strong>normal </strong><br>基于双向算法，元素不打开一个额外的嵌入层次。对于行内元素，在元素的边界中隐含了重排列的工作。<br><strong>embed </strong><br>如果元素是行内的，基于双向算法，该值打开一个额外的嵌入层次。该嵌入层次的方向由’direction’属性给出。在元素内，重排列隐式地完成。这相当     于在元素的开头加入一个LRE（U+202A；对于’direction: ltr’）或RLE（U+202B；对于’direction:      rtl’），在元素的结尾加入一个PDF（U+202C）。<br><strong>bidi-override </strong><br>如果元素是行内的，或者是只包含行内元素的块类元素，该值创建一个超越。这意味着在元素内，重排列严格按照’direction’属性的顺序；双向算法的     隐式部分被忽略。这相当于在元素的开头加入一个LRO（U+202D；对于’direction:      ltr’）或RLO（U+202E；对于’direction: rtl’），在元素的结尾加入一个PDF（U+202C）。<br>每一个块类元素的字符的最终的顺序就如同：双向控制代码如上所述加入，标记被剥离，结果的字符顺序传递给用于普通文字的Unicode双向算法实现，该实     现产生和样式文本一样的分行。在这一处理中，非文字实体如图形被认为是中性字符，除非它们的’unicode-bidi’属性不是设置为     ‘normal’。在这一情况下，它们被认为是为该元素指定的’direction’中的重要字符。</p>
<p>请注意，为了能够在一个单一方向（要么全部左到右，要么全部右到左）中排列行内盒，必须创建更多的行内盒(包括匿名行内盒)，而且某些行内盒在排列之前，可能必须分割或重排。</p>
<p>由于Unicode算法限制嵌入的层次为15层，将’unicode-bidi’设置为非’normal’的使用，必须小心，除非确定是合适的。特别地，    使用’inherit’值时要特别小心。不过，对于那些一般来说显示为块的元素，更应该设置’unicode-bidi:     embed’，这样在显示改变到行内时，可以将元素保持在一起（见下例）。</p>
<p>下面的例子显示了包含双向文字的一个XML文档。它演示了一个重要的设计原则：DTD设计者应该在语言语言（元素和属性）和任何相关联的样式表中考虑双向    因素。样式表的设计应该是双向规则和其它样式表规则分离。双向规则不应该被其它样式表规则超越，从而文档语言或DTD的双向行为得以保留。</p>
<p>例子：</p>
<p>本例中，小写字母表示左到右的字符而大写字母表示右到左的字符：</p>
<p>&lt;HEBREW&gt;<br>&lt;PAR&gt;HEBREW1 HEBREW2 english3 HEBREW4 HEBREW5&lt;/PAR&gt;<br>&lt;PAR&gt;HEBREW6 &lt;EMPH&gt;HEBREW7&lt;/EMPH&gt; HEBREW8&lt;/PAR&gt;<br>&lt;/HEBREW&gt;<br>&lt;ENGLISH&gt;<br>&lt;PAR&gt;english9 english10 english11 HEBREW12 HEBREW13&lt;/PAR&gt;<br>&lt;PAR&gt;english14 english15 english16&lt;/PAR&gt;<br>&lt;PAR&gt;english17 &lt;HE-QUO&gt;HEBREW18 english19 HEBREW20&lt;/HE-QUO&gt;&lt;/PAR&gt;<br>&lt;/ENGLISH&gt;</p>
<p>由于这是一个XML，样式表负责设置书写方向。样式表如下：</p>
<p>/<em> Rules for bidi </em>/<br>HEBREW, HE-QUO  {direction: rtl; unicode-bidi: embed}<br>ENGLISH {direction: ltr; unicode-bidi: embed}</p>
<p>/<em> Rules for presentation </em>/<br>HEBREW, ENGLISH, PAR  {display: block}<br>EMPH {font-weight: bold}</p>
<p>HEBREW元素是一个块，基本方向是右到左，ENGLISH元素是一个块，基本方向是左到右。PAR元素是块，基本方向从父元素继承。因此，前两个     PAR从右顶部开始阅读，最后的三个从左顶布开始阅读。请注意元素名选择HEBREW和ENGLISH只是为了明显表示而已；一般情况下，元素名应该反映    结构而不反映语言。</p>
<p>EMPH元素是行内元素，而且它的’unicode-bidi’设置为’normal’（初始值），它对文字的排列没有影响。另一方面，HE-QUO元素创建一个嵌入。</p>
<p>如果行宽足够的长，这些文字的格式化效果可能是：</p>
<p>5WERBEH 4WERBEH english3 2WERBEH 1WERBEH</p>
<p>8WERBEH 7WERBEH 6WERBEH</p>
<p>english9 english10 english11 13WERBEH 12WERBEH</p>
<p>english14 english15 english16</p>
<p>english17 20WERBEH english19 18WERBEH</p>
<p>注意，HE-QUO嵌入使HEBREW18出现在english19之右。</p>
<p>如果需要分行，可能效果是：</p>
<p>2WERBEH 1WERBEH<br>-EH 4WERBEH english3<br>5WERB</p>
<p>-EH 7WERBEH 6WERBEH<br>8WERB</p>
<p>english9 english10 en-<br>glish11 12WERBEH<br>13WERBEH</p>
<p>english14 english15<br>english16</p>
<p>english17 18WERBEH<br>20WERBEH english19</p>
<p>由于HEBREW18必须在english19前阅读，它在english19所在行的上面。仅仅是在前一格式化例子中分割长行不会有用。还要注意    english19的第一个音节可能可以放在上一行中。但是，为了避免在一行的中间出现一个连字符，在右到左的内容中，左到右单词的连字通常被禁止。反之  亦然。</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/CSS/">CSS</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/w3c标准/">w3c标准</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/翻译/">翻译</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-javacript-e4-b8-ad-e6-9e-84-e5-bb-ba-e5-af-b9-e8-b1-a1-e7-9a-84-e8-8c-83-e5-bc-8f-defining-classes-and-objects-in-javacript" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/08/02/javacript-e4-b8-ad-e6-9e-84-e5-bb-ba-e5-af-b9-e8-b1-a1-e7-9a-84-e8-8c-83-e5-bc-8f-defining-classes-and-objects-in-javacript/" class="article-date">
  <time datetime="2011-08-01T16:01:07.000Z" itemprop="datePublished">2011-08-02</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/javascript-amp-Ajax/">javascript &amp; Ajax</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/08/02/javacript-e4-b8-ad-e6-9e-84-e5-bb-ba-e5-af-b9-e8-b1-a1-e7-9a-84-e8-8c-83-e5-bc-8f-defining-classes-and-objects-in-javacript/">javacript中构建对象的范式_Defining Classes and Objects in javacript</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p><strong>工厂范式 Factory paradigm</strong></p>
<p>function showColor() {<br>alert(this.color);<br>}<br>function createCar(sColor, iDoors, iMpg) {<br>var oTempCar = new Object;<br>oTempCar.color = sColor;<br>oTempCar.doors = iDoors;<br>oTempCar.mpg = iMpg;<br>oTempCar.showColor = showColor;<br>return oTempCar;<br>}<br>var oCar1 = createCar(“red”, 4, 23);<br>var oCar2 = createCar(“blue”, 3, 25);<br>oCar1.showColor(); //outputs “red”<br>oCar2.showColor(); //outputs “blue”</p>
<p>缺点:工厂方法只能创建一种对象,且对象属性固定.</p>
<h3 id="构造器范式-Constructor-paradigm"><a href="#构造器范式-Constructor-paradigm" class="headerlink" title="构造器范式 Constructor paradigm"></a>构造器范式 Constructor paradigm</h3><p>function Car(sColor, iDoors, iMpg) {<br>this.color = sColor;<br>this.doors = iDoors;<br>this.mpg = iMpg;<br>this.showColor = function () {<br>alert(this.color)<br>};<br>}<br>var oCar1 = new Car(“red”, 4, 23);<br>var oCar2 = new Car(“blue”, 3, 25);</p>
<p>When a constructor is called with the new operator, an object is   created before the first line of the constructor is executed; that   object is accessible (at that point) only by using this. It is then   possible to assign properties directly to this that are returned as the   function value by default (no need to explicitly use the return   operator).</p>
<p>这句讲了为啥使用new关键字能使得对象属性可用.并且和java的类构造器很像:</p>
<p>public class Car{<br>public Car(String sColor, String iDoors, String iMpg) {<br>this.color = sColor;<br>this.doors = iDoors;<br>this.mpg = iMpg;<br>}<br>}</p>
<h3 id="原型范式-Prototype-paradigm"><a href="#原型范式-Prototype-paradigm" class="headerlink" title="原型范式 Prototype paradigm"></a>原型范式 Prototype paradigm</h3><p>function Car() {<br>}<br>Car.prototype.color = “red”;<br>Car.prototype.doors = 4;<br>Car.prototype.mpg = 23;<br>Car.prototype.showColor = function () {<br>alert(this.color);<br>};<br>var oCar1 = new Car();<br>var oCar2 = new Car();</p>
<p>这里是javascript最烂的地方,为了使创建的对象实例能够像java一样可以使用对象的属性,其使用了prototype而不是像java一样使用get和set方法.并且java中的prototype模式用于克隆对象.</p>
<h3 id="混合构造器原型范式-Hybrid-constructor-prototype-paradigm"><a href="#混合构造器原型范式-Hybrid-constructor-prototype-paradigm" class="headerlink" title="混合构造器原型范式 Hybrid constructor/prototype paradigm"></a>混合构造器原型范式 Hybrid constructor/prototype paradigm</h3><p>function Car(sColor, iDoors, iMpg) {<br>this.color = sColor;<br>this.doors = iDoors;<br>this.mpg = iMpg;<br>this.drivers = new Array(“Mike”, “Sue”);<br>}<br>Car.prototype.showColor = function () {<br>alert(this.color);<br>};<br>var oCar1 = new Car(“red”, 4, 23);<br>var oCar2 = new Car(“blue”, 3, 25);<br>oCar1.drivers.push(“Matt”);<br>alert(oCar1.drivers); //outputs “Mike,Sue,Matt”<br>alert(oCar2.drivers); //outputs “Mike,Sue”</p>
<p>同样非常烂的一个设计,为了让属性赋值和方法声明分开.说明如下:<br>All the nonfunction properties are  defined in the constructor, meaning  that once again it is possible to  assign default values by passing  arguments into the constructor. Only  one instance of the showColor()  function is being created, so there is  no wasted memory.</p>
<h3 id="动态原型范式-Dynamic-prototype-method"><a href="#动态原型范式-Dynamic-prototype-method" class="headerlink" title="动态原型范式 Dynamic prototype method"></a>动态原型范式 Dynamic prototype method</h3><p>function Car(sColor, iDoors, iMpg) {<br>this.color = sColor;<br>this.doors = iDoors;<br>this.mpg = iMpg;<br>this.drivers = new Array(“Mike”, “Sue”);<br>if (typeof Car._initialized == “undefined”) {<br>Car.prototype.showColor = function () {<br>alert(this.color);<br>};<br>Car._initialized = true;<br>}<br>}</p>
<p>为了使showColor方法只初始化一次.</p>
<h3 id="混合工厂模式-Hybrid-factory-paradigm"><a href="#混合工厂模式-Hybrid-factory-paradigm" class="headerlink" title="混合工厂模式 Hybrid factory paradigm"></a>混合工厂模式 Hybrid factory paradigm</h3><p>function Car() {<br>var oTempCar = new Object;<br>oTempCar.color = “red”;<br>oTempCar.doors = 4;<br>oTempCar.mpg = 23;<br>oTempCar.showColor = function () {<br>alert(this.color)<br>};<br>return oTempCar;<br>}</p>
<p>var car = new Car();</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/javascript/">javascript</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/编程/">编程</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/范式/">范式</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/语言/">语言</a></li></ul>

    </footer>
  </div>
  


</article>
  
    <article id="post-e7-a4-be-e4-bc-9a-e5-8c-96-e7-bd-91-e7-bb-9c-e4-b8-ad-e7-9a-84-e6-95-b0-e5-ad-a6-e6-a8-a1-e5-9e-8b-the-mathematical-model-in-social-network" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2011/07/29/e7-a4-be-e4-bc-9a-e5-8c-96-e7-bd-91-e7-bb-9c-e4-b8-ad-e7-9a-84-e6-95-b0-e5-ad-a6-e6-a8-a1-e5-9e-8b-the-mathematical-model-in-social-network/" class="article-date">
  <time datetime="2011-07-29T15:39:04.000Z" itemprop="datePublished">2011-07-29</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/computer-science/">computer science</a>►<a class="article-category-link" href="/categories/computer-science/web-development/">web development</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2011/07/29/e7-a4-be-e4-bc-9a-e5-8c-96-e7-bd-91-e7-bb-9c-e4-b8-ad-e7-9a-84-e6-95-b0-e5-ad-a6-e6-a8-a1-e5-9e-8b-the-mathematical-model-in-social-network/">社会化网络中的数学模型_The mathematical model in Social Network</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>这里研究的是社会化网络中的一些关系，并归纳了数学模型，具体分为单组信息传播模型和多组信息传播模型.</p>
<p><strong>1.Single group information spread model 单组信息传播模型</strong></p>
<p>这里的研究对象是一组点,并且其存在两种身份,传播者和接收者,在点与点之间存在两种连接关系,单向连接和双向连接.</p>
<p><strong>问题:</strong>求解用户数为n的情况下的最大连接数f(n).</p>
<p>由,<br>f(1) = 0;<br>f(2) = 1;<br>f(3) = 3;<br>f(4) = 6;<br>f(5) = 10;<br>可以得出:<br>f(n) = f(n-1) + (n-1);<br>及:f(n) = f(n-2) + (n-2) + (n-1);<br>f(n) = f(n-3) + (n-3) + (n-2) + (n-1);<br>f(n) = f(1) +1+…+ (n-3) + (n-2) + (n-1);<br><strong>f(n) = n(n-1)/2;</strong></p>
<p>用同样的推倒方式可得出,最小传播连接数:<br><strong>f(n) = n-1;</strong></p>
<p>图示如下:</p>
<p>[caption id=”” align=”alignnone” width=”537”]<img src="http://www.webdevelopmentmachine.com/images/social_net2.jpg" alt="社会化个体关系图"> 社会化个体关系图[/caption]</p>
<p>需要补充的是，这里的连接数指的是两点之间建立的通信连接,<strong>单向连接数最大为:n(n-1)/2.而双向的最大连接数为:n(n-1).同时n趋向无穷大时,无论单双向连接
</strong></p>
<p><strong>lim(n-&gt;∞) f(n) = n*n;</strong></p>
<p>而最小传播连接数指在所有点都建立连接所需的最少连接,它有两种连接方式,一种是环连接,还有一种为发散状连接.其单向最小连接为n-1,而双向则为2(n-1).</p>
<p>并且由以上的关系，可以得到一些推论:</p>
<p><strong>在一组存在完整连接的n个点中(不存在孤点),如果每一个点共享一条信息,在不同连接状态,其值与连接数f(n)相同.也就是说,在存在关联的社会化网络中,如果一个人际圈中有n个用户,每个用户共享一条信息,那么产生的共享信息数值在n到n*n之间.</strong></p>
<h2 id="2-Multigroup-information-spread-model-多组信息传播模型"><a href="#2-Multigroup-information-spread-model-多组信息传播模型" class="headerlink" title="2.Multigroup information spread model 多组信息传播模型"></a>2.Multigroup information spread model 多组信息传播模型</h2><p>在多组信息传播模型中,不同的组,通过一个或者多个点建立连接,然后信息通过建立的层级进行扩散,并且扩散因为连接方式的不同产生不同的信息重叠.</p>
<p>若发散传播组(树状结构如下图),假设每组平均人数为m,传播次数为n,若m&gt;=3,n&gt;=1体系成立,单条信息进行发散,总传递接收次数为 f(m,n)=(m-1)+ (m-1)<sup>2</sup>+ …+ (m-1)<sup>n</sup>;约为 f(m,n)=m+m<sup>2</sup>+ … +m<sup>n</sup>;若信息传播模式为双向则 f(m,n)=2<em>(m-1)+ 2</em>(m-1)<sup>2</sup>+ …+ (m-1)<sup>n</sup>;,约为f(m,n)=2<em>m+2</em>m<sup>2</sup>+ … +2*m<sup>n</sup>;</p>
<p>推导过程如下:</p>
<p><strong>当信息传递模式为单向时,假设组内点数m为固定值3</strong></p>
<p>则在第1次传播时,传递次数为2,即3-1,</p>
<p>在第2次传播时,传递次数为4,即(3-1)<sup>2</sup>,</p>
<p>在第3次传播时,传递次数为8,即(3-1)<sup>3</sup>,</p>
<p>所以总传递次数f(m,n)=(m-1)+ (m-1)<sup>2</sup>+ …+ (m-1)<sup>n</sup>;(m&gt;=3,n&gt;=1)</p>
<p><strong>当信息传递模式为双向时,假设组内点数m为固定值3</strong></p>
<p>则在第1次传播时,传递次数为2,即3-1,</p>
<p>在第2次传播时,传递次数为6,即(3-1)<sup>2</sup>+(3-1),</p>
<p>在第3次传播时,传递次数为12,即(3-1)<sup>3</sup>+(3-1)<sup>2</sup>,</p>
<p>所以总传递次数f(m,n)=2<em>(m-1)+ 2</em>(m-1)<sup>2</sup>+ …+ (m-1)<sup>n</sup>;(m&gt;=3,n&gt;=1)</p>
<p><strong>注:</strong>最后一项没有2倍.</p>
<p>若组人数不定,每次传播会在下一级有若干次则传播接收次数为 f(m,n) = (m<sub>0</sub>-1) + [(m<sub>11</sub>-1) + (m<sub>12</sub>-1)+ .. + (m<sub>1n</sub>-1)]+ .. + [(m<sub>N1</sub>-1) + (m<sub>N2</sub>-1) + .. + (m<sub>Nn</sub>-1)];</p>
<p>示意图如下:</p>
<p>[caption id=”” align=”alignnone” width=”417”]<img src="http://www.webdevelopmentmachine.com/images/mutilgroup_1.jpg" alt="Multigroup information spread model 多组信息传播模型"> Multigroup information spread model 多组信息传播模型[/caption]</p>
<p>若每组中各个点之间信息传送关系都为双向,即边界点会成为组之间的连接点，假设每组平均人数为m,传播次数为n,若m&gt;=3,n&gt;=1体系成立,单条信息进行发散,传递接收次数为 f(m,n)=(m-1)+ 2<em>(m-1)<sup>2</sup>+ …+ 2</em>(m-1)<sup>n</sup>;</p>
<p><strong>假设组内点数m为固定值3,则，</strong></p>
<p>则在第1次传播时,传递次数为2,即3-1,</p>
<p>在第2次传播时,传递次数为6,即2*(3-1)<sup>2</sup>,</p>
<p>在第3次传播时,传递次数为12,即2*(3-1)<sup>3</sup>,</p>
<p>在第n次传播时,传递次数为12,即2*(3-1)<sup>n</sup>,</p>
<p>所以总传递次数 f(m,n)=(m-1)+ 2<em>(m-1)<sup>2</sup>+ …+ 2</em>(m-1)<sup>n</sup>;(m&gt;=3,n&gt;=1)</p>
<p><strong>注:</strong>第一项没有2倍.</p>
<p>[caption id=”” align=”alignnone” width=”415”]<img src="http://www.webdevelopmentmachine.com/images/mutilgroup_2.jpg" alt="Multigroup information spread model 多组信息传播模型"> Multigroup information spread model 多组信息传播模型[/caption]</p>
<p>并由此可以得出一些推论:</p>
<p><strong>传播起始点，接收重复信息(m-1)次,传播重复信息0次.
</strong></p>
<p><strong>中间点接收重复信息(m+1)次,传播重复信息(m-1)次.
</strong></p>
<p><strong>边界点(末端)接收重复信息0次,传播重复信息0次.
</strong></p>
<p><strong>总传播重复次数为: f(n) = (m-1)^2 + (m-1)^3 + … +(m-1)^n;(n&gt;=2)</strong></p>
<p><strong>在一组有连接的点中,一条信息被传递,传播次数介于</strong>(m-1)+ (m-1)<sup>2</sup>+ …+ (m-1)<sup>n</sup> 与(m-1)+ 2<em>(m-1)<sup>2</sup>+ …+ 2</em>(m-1)<sup>n</sup>之间(m&gt;=3,n&gt;=1)</p>

      
    </div>
    <footer class="article-footer">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Structure/">Structure</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/社会化网络/">社会化网络</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/算法/">算法</a></li></ul>

    </footer>
  </div>
  


</article>
  
  
    <nav id="page-nav">
      <a class="extend prev" rel="prev" href="/page/8/">&laquo; Prev</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><a class="page-number" href="/page/8/">8</a><span class="page-number current">9</span><a class="page-number" href="/page/10/">10</a><a class="page-number" href="/page/11/">11</a><span class="space">&hellip;</span><a class="page-number" href="/page/13/">13</a><a class="extend next" rel="next" href="/page/10/">Next &raquo;</a>
    </nav>
  
</section>
        
          <aside id="sidebar">
  
    <div class="widget-wrap">
  <h3 class="widget-title">Github</h3>
  <div class="widget">
    <ul class="category-list"><li class="category-list-item"><a href="https://github.com/rainzhai">https://github.com/rainzhai</a></li></ul>
  </div>
</div>

  <div class="widget-wrap">
    <h3 class="widget-title">分类 Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/CSS/">CSS</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS-amp-HTML/">CSS &amp; HTML</a><span class="category-list-count">29</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/CSS-amp-HTML/html5/">html5</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS-amp-HTML/javascript-amp-Ajax/">javascript &amp; Ajax</a><span class="category-list-count">2</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/CSS-amp-HTML/javascript-amp-Ajax/移动端开发/">移动端开发</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS-amp-HTML/web-development/">web development</a><span class="category-list-count">2</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/CSS-amp-HTML/web-development/移动端开发/">移动端开发</a><span class="category-list-count">1</span></li></ul></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/blog/">blog</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/computer-science/">computer science</a><span class="category-list-count">10</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/computer-science/java-web/">java web</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/computer-science/web-development/">web development</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/computer-science/算法/">算法</a><span class="category-list-count">2</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/html5/">html5</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/hybrid/">hybrid</a><span class="category-list-count">2</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/hybrid/phonegap/">phonegap</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/java-web/">java web</a><span class="category-list-count">10</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/javascript-amp-Ajax/">javascript &amp; Ajax</a><span class="category-list-count">23</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/javascript-amp-Ajax/jquery/">jquery</a><span class="category-list-count">1</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/javascript-amp-Ajax/jquery/web-development/">web development</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/javascript-amp-Ajax/web-development/">web development</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/javascript-amp-Ajax/算法/">算法</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/jquery/">jquery</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nodejs/">nodejs</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/php/">php</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/web-development/">web development</a><span class="category-list-count">15</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/前端/">前端</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/智趣/">智趣</a><span class="category-list-count">5</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/智趣/游戏/">游戏</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/智趣/生活/">生活</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/未分类/">未分类</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/模块化/">模块化</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/游戏/">游戏</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/生活/">生活</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/资源/">资源</a><span class="category-list-count">1</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签 Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Angularjs/">Angularjs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CSS/">CSS</a><span class="tag-list-count">21</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CSS-3/">CSS 3</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/D2/">D2</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/DIY/">DIY</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Design/">Design</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Structure/">Structure</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/android/">android</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/app/">app</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/">blog</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/bug/">bug</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/css3/">css3</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/debug/">debug</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dojo/">dojo</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/easy-ui/">easy ui</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/firefox/">firefox</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flash/">flash</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/free-hosting/">free hosting</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/game/">game</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/geekTime/">geekTime</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/html/">html</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/html5/">html5</a><span class="tag-list-count">18</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hybrid/">hybrid</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ie/">ie</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ios/">ios</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javascript/">javascript</a><span class="tag-list-count">28</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jquery/">jquery</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jquery-mobile/">jquery mobile</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jsp/">jsp</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mobile/">mobile</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/">nodejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/npm/">npm</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/photos/">photos</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/php/">php</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/requirejs/">requirejs</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/seam/">seam</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/svg/">svg</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/threejs/">threejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ued/">ued</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/w3c标准/">w3c标准</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/web/">web</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/webapp/">webapp</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/webgl/">webgl</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/webpage/">webpage</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wordpress/">wordpress</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/上下文/">上下文</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/分享/">分享</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/前端/">前端</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/前端-Javascript-css-ES6/">前端 Javascript css ES6</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/学习/">学习</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/性能/">性能</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/总结/">总结</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/效率/">效率</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/模块化/">模块化</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/游戏/">游戏</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/理论/">理论</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/生活/">生活</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/社会化网络/">社会化网络</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/移动/">移动</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/移动端开发/">移动端开发</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/算法/">算法</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/编程/">编程</a><span class="tag-list-count">18</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/美女/">美女</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/翻译/">翻译</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/范式/">范式</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/设计模式/">设计模式</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/语义网/">语义网</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/语言/">语言</a><span class="tag-list-count">21</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/资源/">资源</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/转载/">转载</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/面向对象/">面向对象</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/风景/">风景</a><span class="tag-list-count">1</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签云 Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Angularjs/" style="font-size: 10px;">Angularjs</a> <a href="/tags/CSS/" style="font-size: 19.09px;">CSS</a> <a href="/tags/CSS-3/" style="font-size: 13.64px;">CSS 3</a> <a href="/tags/D2/" style="font-size: 10px;">D2</a> <a href="/tags/DIY/" style="font-size: 10px;">DIY</a> <a href="/tags/Design/" style="font-size: 10.91px;">Design</a> <a href="/tags/Structure/" style="font-size: 16.36px;">Structure</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/app/" style="font-size: 10px;">app</a> <a href="/tags/blog/" style="font-size: 10.91px;">blog</a> <a href="/tags/bug/" style="font-size: 10px;">bug</a> <a href="/tags/css3/" style="font-size: 14.55px;">css3</a> <a href="/tags/debug/" style="font-size: 10px;">debug</a> <a href="/tags/dojo/" style="font-size: 10px;">dojo</a> <a href="/tags/easy-ui/" style="font-size: 10px;">easy ui</a> <a href="/tags/firefox/" style="font-size: 10px;">firefox</a> <a href="/tags/flash/" style="font-size: 10px;">flash</a> <a href="/tags/free-hosting/" style="font-size: 10px;">free hosting</a> <a href="/tags/game/" style="font-size: 10px;">game</a> <a href="/tags/geekTime/" style="font-size: 10px;">geekTime</a> <a href="/tags/html/" style="font-size: 13.64px;">html</a> <a href="/tags/html5/" style="font-size: 18.18px;">html5</a> <a href="/tags/hybrid/" style="font-size: 11.82px;">hybrid</a> <a href="/tags/ie/" style="font-size: 10.91px;">ie</a> <a href="/tags/ios/" style="font-size: 10px;">ios</a> <a href="/tags/java/" style="font-size: 17.27px;">java</a> <a href="/tags/javascript/" style="font-size: 20px;">javascript</a> <a href="/tags/jquery/" style="font-size: 15.45px;">jquery</a> <a href="/tags/jquery-mobile/" style="font-size: 10.91px;">jquery mobile</a> <a href="/tags/jsp/" style="font-size: 10px;">jsp</a> <a href="/tags/mobile/" style="font-size: 10.91px;">mobile</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/npm/" style="font-size: 10px;">npm</a> <a href="/tags/photos/" style="font-size: 10px;">photos</a> <a href="/tags/php/" style="font-size: 10px;">php</a> <a href="/tags/requirejs/" style="font-size: 10.91px;">requirejs</a> <a href="/tags/seam/" style="font-size: 10.91px;">seam</a> <a href="/tags/svg/" style="font-size: 10px;">svg</a> <a href="/tags/threejs/" style="font-size: 10px;">threejs</a> <a href="/tags/ued/" style="font-size: 10.91px;">ued</a> <a href="/tags/w3c标准/" style="font-size: 12.73px;">w3c标准</a> <a href="/tags/web/" style="font-size: 13.64px;">web</a> <a href="/tags/webapp/" style="font-size: 10.91px;">webapp</a> <a href="/tags/webgl/" style="font-size: 10px;">webgl</a> <a href="/tags/webpage/" style="font-size: 10.91px;">webpage</a> <a href="/tags/wordpress/" style="font-size: 11.82px;">wordpress</a> <a href="/tags/上下文/" style="font-size: 10px;">上下文</a> <a href="/tags/分享/" style="font-size: 10.91px;">分享</a> <a href="/tags/前端/" style="font-size: 16.36px;">前端</a> <a href="/tags/前端-Javascript-css-ES6/" style="font-size: 10px;">前端 Javascript css ES6</a> <a href="/tags/学习/" style="font-size: 10px;">学习</a> <a href="/tags/性能/" style="font-size: 12.73px;">性能</a> <a href="/tags/总结/" style="font-size: 10.91px;">总结</a> <a href="/tags/效率/" style="font-size: 11.82px;">效率</a> <a href="/tags/模块化/" style="font-size: 10.91px;">模块化</a> <a href="/tags/游戏/" style="font-size: 11.82px;">游戏</a> <a href="/tags/理论/" style="font-size: 14.55px;">理论</a> <a href="/tags/生活/" style="font-size: 10.91px;">生活</a> <a href="/tags/社会化网络/" style="font-size: 10.91px;">社会化网络</a> <a href="/tags/移动/" style="font-size: 10px;">移动</a> <a href="/tags/移动端开发/" style="font-size: 10px;">移动端开发</a> <a href="/tags/算法/" style="font-size: 13.64px;">算法</a> <a href="/tags/编程/" style="font-size: 18.18px;">编程</a> <a href="/tags/美女/" style="font-size: 10px;">美女</a> <a href="/tags/翻译/" style="font-size: 13.64px;">翻译</a> <a href="/tags/范式/" style="font-size: 12.73px;">范式</a> <a href="/tags/设计模式/" style="font-size: 11.82px;">设计模式</a> <a href="/tags/语义网/" style="font-size: 10px;">语义网</a> <a href="/tags/语言/" style="font-size: 19.09px;">语言</a> <a href="/tags/资源/" style="font-size: 10.91px;">资源</a> <a href="/tags/转载/" style="font-size: 10px;">转载</a> <a href="/tags/面向对象/" style="font-size: 10px;">面向对象</a> <a href="/tags/风景/" style="font-size: 10px;">风景</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">文章 Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/07/">July 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/06/">June 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">August 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">July 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">April 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">March 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/08/">August 2015</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/12/">December 2014</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/11/">November 2014</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/10/">October 2014</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/05/">May 2014</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/04/">April 2014</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/03/">March 2014</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/02/">February 2014</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/01/">January 2014</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/12/">December 2013</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/11/">November 2013</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/10/">October 2013</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/09/">September 2013</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/08/">August 2013</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/07/">July 2013</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/06/">June 2013</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/05/">May 2013</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/03/">March 2013</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/01/">January 2013</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/11/">November 2012</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/08/">August 2012</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/06/">June 2012</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/05/">May 2012</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/04/">April 2012</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/03/">March 2012</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/02/">February 2012</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/01/">January 2012</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/12/">December 2011</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/11/">November 2011</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/10/">October 2011</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/09/">September 2011</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/08/">August 2011</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/07/">July 2011</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/06/">June 2011</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/04/">April 2011</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/02/">February 2011</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/01/">January 2011</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/12/">December 2010</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/11/">November 2010</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/10/">October 2010</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/09/">September 2010</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/08/">August 2010</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/06/">June 2010</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/04/">April 2010</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/01/">January 2010</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2009/08/">August 2009</a><span class="archive-list-count">1</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最近 Recents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2018/07/23/nvm安装问题处理-nvm-is-not-compatible-with-the-npm-config-prefix-option-错误/">nvm安装问题处理 nvm is not compatible with the npm config prefix option 错误</a>
          </li>
        
          <li>
            <a href="/2018/06/06/前端知识体系大全/">前端知识体系大全</a>
          </li>
        
          <li>
            <a href="/2016/08/28/使用Angularjs开发控制台类项目/">使用Angularjs开发控制台类项目</a>
          </li>
        
          <li>
            <a href="/2016/07/11/Apicloud开发app的问题总结/">Apicloud开发app的问题总结</a>
          </li>
        
          <li>
            <a href="/2016/04/25/前端面试经典问题/">前端面试经典问题</a>
          </li>
        
      </ul>
    </div>
  </div>

  
      <div class="widget-wrap">
<h3 class="widget-title">友情链接 Links</h3>
<div class="widget">
<ul>
<li><a href="http://wande.me" title="玩的么" target="_blank">玩的么</a></li>
</ul>
</ul>
</div>
  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 宅鱼<br>
      更多游戏： <a href="http://wande.me"  target="_blank">玩的么</a><br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">首页</a>
  
    <a href="/archives" class="mobile-nav-link">文章</a>
  
    <a href="/raincss" class="mobile-nav-link">RainCSS</a>
  
</nav>
    <!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"rainzhai"};
  (function() {
    var ds = document.createElement('script');
    ds.type = 'text/javascript';ds.async = true;
    ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
    ds.charset = 'UTF-8';
    (document.getElementsByTagName('head')[0] 
     || document.getElementsByTagName('body')[0]).appendChild(ds);
  })();
  </script>
<!-- 多说公共JS代码 end -->

<script type="text/javascript" src="http://wandeme.com/js/jquery-1.7.2.min.js"></script>

<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F49ba6eabd43121d820d9120777bdaf30' type='text/javascript'%3E%3C/script%3E"));
</script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>